2.7. Testing results that are system state changes instead of return values

Up until this section, you’ve seen how to test for the first, simplest kind of result a unit of work can have: return values (explained in chapter 1). Here and in the next chapter we’ll also discuss the second type of result: system state change—checking that the system’s behavior is different after performing an action on the system under test.


State-based testing (also called state verification) determines whether the exercised method worked correctly by examining the changed behavior of the system under test and its collaborators (dependencies) after the method is exercised.

If the system acts exactly the same as it did before, then you ...

Get The Art of Unit Testing, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.