Jump to content

Mockito

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Mawcs (talk | contribs) at 20:18, 29 December 2010 (Added detail to the stub to make it more notable and to reduce the impact of jargon.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Mockito is an open source testing framework for Java released under the MIT License. The framework allows the creation of Test Double objects called, "Mock Objects" in automated unit tests for the purpose of Test-driven Development (TDD) or Behavior Driven Development (BDD).

Distinguishing Features

Mockito distinguishes itself from other mocking frameworks by allowing developers to verify the behavior of the system under test (SUT) without establishing expectations beforehand[1]. One of the criticisms of Mock objects is that there is a tighter coupling of the test code to the SUT object code [2]. Since Mockito attempts to eliminate the expect-run-verify pattern[3] by removing the specification of expectations, the coupling is reduced or minimized. The result of this distinguishing feature is simpler test code that should be easier to read and modify.

Origins

Faber Szczepan started the Mockito project after finding existing mocking frameworks too complex and difficult to work with. Szczepan began by expanding on the syntax and functionality of Easy Mock, but eventually settled on writing Mockito from scratch[4]. Szczepan's goal was to create a new framework that was easier to work with and provided better results. Early versions of Mockito project found use by the Guardian project in London in early 2008[5].

Usage

Mockito has a growing user-base [6] as well as finding use in other open source projects [7]. In the Stack Overflow discussion on What's the best mock framework for Java?, Mockito is the highest recommended answer [8].

See Also

References

  1. ^ "Features and Motivations". Retrieved 2010-12-29.
  2. ^ Fowler, Martin (2007). "Mocks Aren't Stubs". Retrieved 2010-12-29.
  3. ^ Faber, Szczepan. "Death Wish". Retrieved 2010-12-29.
  4. ^ Faber, Szczepan. "Mockito". Retrieved 2010-12-29.
  5. ^ "Mockito Home Page". Retrieved 2010-12-29.
  6. ^ "Mockito User Base". Retrieved 2010-12-29.
  7. ^ "Mockito in Use". Retrieved 2010-12-29.
  8. ^ "What's the best mock framework for Java?". Retrieved 2010-12-29.