liveBook · Manning

Isolation

As explained in Unit Testing Principles, Practices, and Patterns

The isolation attribute is the aspect of unit testing that specifies what a test or system under test must be isolated from.

Isolation specifies what unit tests or the system under test must be separated from. The London school isolates the system under test from collaborators; the classical school isolates tests from one another. section 2.2

The two interpretations lead to different testing boundaries:

  • London-style tests treat a class as the unit and replace mutable dependencies, while retaining immutable values. section 2.2
  • Immutable values such as numbers, enums, and value objects need no test doubles because their contents cannot change. section 2.2

Purchase with isolated inventory

A purchase test substitutes the mutable store with a mock, configures insufficient inventory, asserts failure, and verifies that inventory removal never occurs.

How Unit Testing Principles, Practices, and Patterns covers it

How deep it goes
Distinguishes isolation targets and dependency treatment, then stops short of broader test-design guidance.
Examples
Uses a mocked store, immutable product values, inventory failure, and interaction verification.
What you can do after
Evaluate whether a dependency should be replaced by a test double based on mutability and sharing.
How it connects
Connects isolation with unit boundaries, dependencies, test doubles, shared dependencies, mutable objects, and immutable values.

Also explained in

Compare how 8 books explain isolation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Unit Testing Principles, Practices, and Patterns. The section links point to the parts of the book it draws on.