A private dependency is not shared between tests, so its state cannot transmit interference between their executions. A test may create and reuse its own instance without making that dependency shared. section 2.1
Classify private dependencies by whether their state can change:
- An immutable private dependency is a value object; equivalent instances can be used interchangeably. section 2.2
- A mutable private dependency can change during a test but remains private when tests do not reuse the same instance. section 2.2 section 2.1
Private dependencies do not require replacement merely to isolate tests. The classical approach keeps them intact, while the London approach replaces mutable private dependencies as well as shared ones; immutable dependencies remain intact. section 2.2
Store and Product
A Store created inside each purchase test is a mutable private dependency. Product.Shampoo is an immutable private dependency, or value object. A database reused by tests is shared instead, because its state can affect other tests. section 2.2 section 2.1
