Skip to Content
Effective Software Testing
book

Effective Software Testing

by Mauricio Aniche
April 2022
Intermediate to advanced
328 pages
9h 56m
English
Manning Publications
Content preview from Effective Software Testing

6 Test doubles and mocks

This chapter covers

  • Using stubs, fakes, and mocks to simplify testing
  • Understanding what to mock, when to mock, and when not to mock
  • How to mock the unmockable

Until now, we have been testing classes and methods that were isolated from each other. We passed the inputs to a single method call and asserted its output. Or, when a class was involved, we set up the state of the class, called the method under test, and asserted that the class was in the expected state.

But some classes depend on other classes to do their job. Exercising (or testing) many classes together may be desirable. We often break down complex behavior into multiple classes to improve maintainability, each with a small part of the business logic. We ...

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.
Start your free trial

You might also like

Effective Software Testing

Effective Software Testing

Mauricio Aniche
The Art of Software Testing, 3rd Edition

The Art of Software Testing, 3rd Edition

Glenford J. Myers, Corey Sandler, Tom Badgett
Software Testing: Principles and Practices

Software Testing: Principles and Practices

Srinivasan Desikan, Gopalaswamy Ramesh

Publisher Resources

ISBN: 9781633439931Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentErrata PagePurchase Link