
Mockito
Mockito is a free Java mocking framework for writing unit tests.
What Mockito is
Mockito is a free Java mocking framework for writing unit tests. Developers can create mocks of interfaces and concrete classes, set their behavior before code runs, and verify selected interactions afterward. Verification options include checking call order, exact or minimum call counts, and arguments with flexible matching. Spies allow partial mocking: real methods can run while still being stubbed and verified. The API also provides @InjectMocks for injecting mock or spy fields. The project recommends adding the mockito-core dependency through a build system and provides Maven Central and Gradle setup instructions, with pointers for other build tools. Android use is possible with Dexmaker. Mockito 5 requires Java 11, while mockito-android tests require an Android P (API 28) or newer device or emulator. The project is MIT licensed and points users to Stack Overflow, a moderated mailing list, and GitHub issues for help. Commercial support and maintenance are available through a Tidelift subscription. The project advises against indiscriminate mocking, including mocking types developers do not own or value objects.
Good
- Mocks interfaces and concrete classes
- Supports ordered and count-based verification
- Spies allow partial mocking
- MIT licensed and free
Watch out
- Mockito 5 requires Java 11
- Android tests require API 28 or newer
- Commercial support requires a Tidelift subscription
Who it suits
Mockito suits Java developers writing unit tests who need to control dependencies and check interactions. Android developers can use it with Dexmaker, subject to the stated platform requirements.
Verdict
Mockito offers a focused set of mocking, stubbing, and verification tools for Java unit tests. Developers should account for its Java and Android requirements and follow the project's guidance against indiscriminate mocking.
Plans and prices
From Mockito's own pricing page, checked 9 Oct 2001.
| Plan | Price | What it gives you |
|---|---|---|
| Mockito | Free | Open-source Java mocking framework |
The facts
Each one read from Mockito's own pages, with the date it was checked.
Where it runs
- Android
- The site says Mockito can be used on Android with Dexmaker.checked 9 Oct 2001
- Android requirement
- The v5.23.0 release notes state that mockito-android tests require an Android P (API 28) or newer device or emulator.checked 9 Oct 2001
What it does
- Argument matching
- Mockito supports flexible argument matching for verification and stubbing.checked 9 Oct 2001
- Build tools
- The site gives Maven Central and Gradle dependency setup instructions and refers users to other build systems.checked 9 Oct 2001
- Distribution
- The recommended installation method is adding the mockito-core dependency through a build system.checked 9 Oct 2001
- Enterprise support
- The repository says commercial support and maintenance are available through a Tidelift subscription.checked 9 Oct 2001
- Help
- The project points users to Stack Overflow, a moderated mailing list, and its GitHub issue tracker for help.checked 9 Oct 2001
- Java requirement
- The repository says Mockito 5 requires Java 11.checked 9 Oct 2001
- License
- The repository publishes Mockito under the MIT License.checked 9 Oct 2001
- Mocking
- It can mock concrete classes as well as interfaces.checked 9 Oct 2001
- Partial mocks
- Its spy feature invokes real methods while allowing them to be verified and stubbed.checked 9 Oct 2001
- Purpose
- Mockito is a mocking framework for writing unit tests in Java.checked 9 Oct 2001
- Security
- The repository links to a security policy.checked 9 Oct 2001
- Spies and injection
- Its API includes spies for partial mocking and @InjectMocks for injecting mock or spy fields.checked 9 Oct 2001
- Stubbing and verification
- Mockito lets developers stub behavior before execution and verify selected interactions afterward.checked 9 Oct 2001
- Support
- The project directs users to its mailing list for questions and documentation feedback, and GitHub for bugs and feature requests.checked 9 Oct 2001
- Training
- Mockito core engineers offer team training on test automation with mock objects, behavior-driven development, and maintainable tests.checked 9 Oct 2001
- Use guidance
- The project advises against mocking types you do not own, value objects, or everything indiscriminately.checked 9 Oct 2001
- Verification options
- It supports ordered verification, exact or minimum call counts, and flexible argument matching.checked 9 Oct 2001




