TechnoBuzz

A Techno Blog, mainly about Java

Mock Objects

A mock object conforms to the interface of the real object, but has just enough code to fool the tested object and track its behavior.

  • Target object: The object being tested
  • Collaborator object: The object created or obtained by the target
  • Mock object: A subclass (or implementation) of the collaborator that follows the mock object pattern.
  • Specialization object: A subclass of the target that overrides the creation method to return a mock instead of a collaborator
  • Unit testing is the testing of software units in isolation. However, most units do not work alone, but they collaborate with other units. Mock objects are Replacements for collaborators.

    EasyMock provides an easy way to use Mock Objects for given interfaces in  JUNIT tests.

    February 25, 2005 Posted by | SW Tools | Leave a comment