Mock Object

A mock object is a dummy implementation of an interface or class in which you define the output of certain method calls.

A mock has the same method signatures as the real object, but:

  • Records how other objects interact with it (which methods are called, with what arguments).
  • There is a mock instance of the object, but no real object instance.

Stubbing is the related technique of returning whatever canned value we pass in.