Chapter 4. Interaction testing using mock objects
This chapter covers
- Defining interaction testing
- Understanding mock objects
- Differentiating fakes, mocks, and stubs
- Exploring mock object best practices
In the previous chapter, you solved the problem of testing code that depends on other objects to run correctly. You used stubs to make sure that the code under test received all the inputs it needed so that you could test its logic independently.
Also, so far, you’ve only written tests that work against the first two of the three types of end results a unit of work can have: returning a value and changing the state of the system.
In this chapter, we’ll look at how you test the third type of end result—a call to a third-party object. You’ll ...
Get The Art of Unit Testing, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.