This chapter covers
Introducing and demonstrating mock objects
Performing different refactorings
Using mock objects to verify API contracts on collaborating classes
Practicing on an HTTP connection sample application
The secret of success is sincerity. Once you can fake that you’ve got it made.
Unit-testing each method in isolation from the other methods or the environment is certainly a nice goal. But how do you perform this feat? You saw in chapter 6 how the stubbing technique lets you unit-test portions of code by isolating them from the environment (for example, by stubbing a web server, the filesystem, a database, and so on). But what about fine-grained isolation like being able ...