How do you write tests for a system that does not return an output but changes another object’s state instead?
By spying on the object affected by the SUT.
If you have control over the object on which the side effect occurs, you can inspect its state to verify it matches your expectation, but what if you don’t? For example, how can you verify that an object calls a method on a third-party SDK as a result of a particular operation?
This chapter introduces a new kind of Test Double that allows us to do precisely that: the Spy. Using a Spy, you can replace a real dependency of your SUT ...