Chapter 12. Test Doubles
In Chapter 9, “Dependencies,” we learned how to expose and pass around collaborators to make dependencies explicit and break them. It’s perfectly natural that program elements, most notably objects, somehow depend on each other, but such relations have to be controllable. In this chapter, the subject will be revisited and explored in greater detail. Dependencies can be controlled in several ways, depending on what part they play in a test. Sometimes collaborating objects should be ignored, which may not be as easy as it sounds. Sometimes they’re of paramount importance and must be surveilled with utmost scrutiny.
Test double1 is a general term for an object that replaces a collaborator. Different kinds of test doubles ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access