2.6. Every trade has its tools and tests are no exception

What’s this test double I speak of? If you don’t have test doubles in your programmer’s toolkit, you’re missing out on a lot of testing power. Test double is an umbrella term for what some programmers have come to know as stubs, fakes, or mocks (which is short for mock object). Essentially they’re objects that you substitute for the real implementation for testing purposes. See figure 2.4.

Figure 2.4. A test double for a duck looks just like a duck and quacks almost like a duck—but certainly isn’t a real duck.

You could say that test doubles are a test-infected programmer’s best friend. ...

Get Effective Unit Testing 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.