10 Pines Blog

Be careful with the mocks

tests mocks

Mocking objects is a common practice when writing tests, however it can be painful when refactoring a class tested with mocks. I will show a simple example to explain the problems that mocking can generate, but first I would like to give some definitions:

  • Stubs are objects that respond to a subset of messages from the object to be stubbed with specific responses.
  • Mocks are objects that verify the integration between the system under test and the mocked object.
  • Fake are objects with implementation that simulate the real one but they are simpler and/or faster.

14 Jan 2016