A dependency is a component, object, service, or value that code under test relies on. Testing strategy depends on whether it is mutable, shared, or out-of-process. section 2.2
Use these distinctions when choosing real dependencies or test doubles:
- Keep immutable values and value objects real; substitute mutable dependencies when isolation requires it. section 2.2
- The London school isolates the system under test and replaces mutable dependencies; the classical school isolates tests and replaces shared dependencies. section 2.2
- Prefer explicit injection over ambient context, and pass time as a value when practical. section 11.6
Purchase and time
A purchase test keeps Product.Shampoo and 5 real while mocking the mutable Store. For time, inject a clock service at the operation boundary, then pass its DateTime value into domain logic. section 2.2 section 11.6
Table 2.1. The differences between the London and classical schools of unit testing, summed up by the approach to isolation, the size of a unit, and the use of test doubles (view table figure)
| Isolation of |
A unit is |
Uses test doubles for |
|
|---|---|---|---|
| London school | Units | A class | All but immutable dependencies |
| Classical school | Unit tests | A class or a set of classes | Shared dependencies |
Compare isolation targets, unit sizes, and test-double boundaries across the two testing schools. section 2.2


























