Skip to Content
Unit Testing Principles, Practices, and Patterns
book

Unit Testing Principles, Practices, and Patterns

by Vladimir Khorikov
January 2020
Intermediate to advanced
304 pages
9h 8m
English
Manning Publications
Content preview from Unit Testing Principles, Practices, and Patterns

Chapter 5. Mocks and test fragility

This chapter covers

  • Differentiating mocks from stubs
  • Defining observable behavior and implementation details
  • Understanding the relationship between mocks and test fragility
  • Using mocks without compromising resistance to refactoring

Chapter 4 introduced a frame of reference that you can use to analyze specific tests and unit testing approaches. In this chapter, you’ll see that frame of reference in action; we’ll use it to dissect the topic of mocks.

The use of mocks in tests is a controversial subject. Some people argue that mocks are a great tool and apply them in most of their tests. Others claim that mocks lead to test fragility and try not to use them at all. As the saying goes, the truth lies somewhere ...

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

Unit Testing Principles, Practices, and Patterns

Unit Testing Principles, Practices, and Patterns

Vladimir Khorikov
Design Patterns: Elements of Reusable Object-Oriented Software

Design Patterns: Elements of Reusable Object-Oriented Software

Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides

Publisher Resources

ISBN: 9781617296277Publisher SupportOtherPublisher WebsiteSupplemental ContentErrata PagePurchase Link