Mockito
![]() | This article may be too technical for most readers to understand.(February 2010) |
![]() | The topic of this article may not meet Wikipedia's general notability guideline. (February 2010) |
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
- List of mock object frameworks
- Behavior driven development
- Mock object
- List of unit testing frameworks
- Software testing
- Unit testing
References
- ^ "Features and Motivations". Retrieved 2010-12-29.
- ^ Fowler, Martin (2007). "Mocks Aren't Stubs". Retrieved 2010-12-29.
- ^ Faber, Szczepan. "Death Wish". Retrieved 2010-12-29.
- ^ Faber, Szczepan. "Mockito". Retrieved 2010-12-29.
- ^ "Mockito Home Page". Retrieved 2010-12-29.
- ^ "Mockito User Base". Retrieved 2010-12-29.
- ^ "Mockito in Use". Retrieved 2010-12-29.
- ^ "What's the best mock framework for Java?". Retrieved 2010-12-29.