Chapter 6. Mock Objects and Stubs

Mocks and stubs are essential to any test-driven or behavior-driven testing frameworks:

 

"The term 'Mock Objects' has become a popular one to describe special case objects that mimic real objects for testing. Most language environments now have frameworks that make it easy to create mock objects. What's often not realized, however, is that mock objects are but one form of special case test object, one that enables a different style of testing."

 
 --Martin Fowler

In this chapter, we will discuss:

  • History of mock objects
  • Couplings
  • Stubs
  • Mocks
  • Fakes
  • Spy
  • Mocking frameworks

History

During one of my several Agile incarnations, I had the opportunity to work with Tim Mackinnon who was involved in the development of the concept ...

Get Scala Test-Driven Development 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.