A unit test is an automated check that runs in isolation from external dependencies. Its unit may be a method, several methods, or an entire feature; the defining property is isolation, with dependencies controlled through mocks. section 11.1
Isolation makes deep and exhaustive checks practical across a wide state space, but it also limits the test to approximating the outside world. Integration tests complement it by exercising dependencies and input/output. section 11.6
Effective unit tests make their data and intent visible:
- Keep relevant inputs, transformations, and assertions together so the link between data and expected behavior is clear. section 11.8
- Parameterize fixtures and generate varied values to expose rarely exercised states and avoid secret couplings created by hard-coded data. section 11.8
- Choose the strategy for the application and problem rather than treating a testing pyramid or coverage target as a universal rule. section 11.6
One test, several scales
A test can generate ten accounts for a quick isolated check, then use the same assertions with 1,000 or 1,000,000 accounts to investigate load behavior. Changing the data volume changes the role without changing the test’s core logic. section 11.5.3
Listing 11.51 The same test can fill multiple roles just by changing the amount of data
Set<Account> accounts = generate(this::mkAcnt)
.limit(10) #A
// .limit(1000) #A
// .limit(1_000_000) #A
.collect(toSet());
// rest of test is the same Compare the same generated test at small, medium, and million-item data volumes. section 11.5.3

















