When a test cannot rely on a fixture’s exact starting state, check how much the code changes it instead of asserting an absolute result. Record the initial state, exercise the code, then compare the result with the expected change. section 4.5.1
Listing 4.10. Example of the Delta Assertion pattern
The test saves the list size before adding an item, then checks that the size increased by one. section 4.5.1
This makes the assertion reflect what the test is really checking—the effect of adding an item—without depending on a particular starting size. section 4.5.1
