A real dependency is something a test uses as it actually exists: another component, service, clock, network, database, thread, or random-number generator. Because the test does not fully control it, its state or behavior can affect the result. section 1.8
Tests using real dependencies are integration tests. They exercise units working together, while unit tests isolate a unit from dependencies so behavior can be controlled and simulated consistently. section 1.8
Real dependencies make a test useful for checking collaboration, but introduce practical costs:
- More possible failure points make the cause of a failed overall operation harder to locate. section 1.8
- Changing shared code or data can make earlier tests fail and expose regressions: functionality that previously worked but no longer does. section 1.8
- Use isolated tests when consistent, controllable simulation of a unit's behavior matters most. section 1.8
Figure 1.7 You can have many failure points in an integration test. All the units have to work together, and each could malfunction, making it harder to find the source of a bug.
A single operation can cross many units; any one of them can malfunction, so an integration-test failure identifies the operation but not necessarily its cause. section 1.8
