Freedom251 › Unit Testing Frameworks
Mockito

What Mockito is
Mockito is a free Java mocking framework for writing unit tests. It creates test doubles for concrete classes and interfaces, allowing developers to define behavior before code runs and inspect selected interactions afterward. Verification can check call order, require exact or minimum invocation counts, and use flexible argument matching. Spies support partial mocking: real methods execute while remaining available for stubbing and verification. The API also provides @InjectMocks for placing mock or spy fields into the object under test. Mockito is distributed by adding the mockito-core dependency through a build system, with setup guidance for Maven Central and Gradle and references to other build systems. Android use is available with Dexmaker; mockito-android tests require an Android P (API 28) or newer device or emulator. Mockito 5 requires Java 11. The project identifies an MIT license and lists Android, Linux, and self-hosted platforms. Help channels include Stack Overflow, a moderated mailing list, and GitHub issues. Commercial support and maintenance are available through Tidelift, and core engineers offer team training on test automation, behavior-driven development, and maintainable tests.
Who it suits
Mockito suits Java developers writing unit tests who need controllable substitutes for interfaces or concrete classes. It also fits teams using partial mocks, interaction verification, Maven or Gradle, or Android testing with Dexmaker.
What it does well
- Mocks interfaces and concrete classes
- Supports ordered and call-count verification
- Spies run real methods while remaining stub-able
- Provides @InjectMocks field injection
- MIT-licensed and free to use
- Offers Maven Central and Gradle setup guidance
What to know first
- Mockito 5 requires Java 11
- Android mockito-android tests require Android P or newer
- There is no free trial period
- Commercial support and maintenance are available through a Tidelift subscription
Limits
Mockito is listed as a free plan costing free, with no free trial. Mockito 5 requires Java 11, and mockito-android tests require Android P (API 28) or newer.
Plans
| Plan | Billed and limits | Price |
|---|---|---|
| Mockito | Open-source Java mocking framework | Free |
As site.mockito.org lists them, read 9 Oct 2026. The maker's own page has the final word.
Getting started
- Open the Mockito website
- Add the mockito-core dependency through Maven Central, Gradle, or another build system
- Use Mockito with Java unit tests
- For Android, add Dexmaker-based Mockito support
- Ensure Mockito 5 uses Java 11
- For mockito-android tests, use an Android P (API 28) or newer device or emulator
Verdict
Pick Mockito for Java unit tests that need stubbing, interaction checks, spies, or injected mocks. Its free MIT-licensed distribution and build-system setup suit development teams. Look elsewhere if your environment cannot use Java 11, or if Android testing cannot meet the Android P requirement.
Questions
Is Mockito free?
Yes. Mockito has a free plan listed as free and is MIT licensed.
Which language does Mockito support?
The supported language listed for Mockito is Java.
How do I install Mockito?
The recommended route is adding the mockito-core dependency through a build system. Setup instructions are provided for Maven Central and Gradle, with references to other build systems.
Can Mockito be used on Android?
Yes. The project describes Android use with Dexmaker. Mockito-android tests require an Android P (API 28) or newer device or emulator.
What verification does Mockito provide?
It supports ordered verification, exact or minimum call counts, and flexible argument matching.
Where can users get help?
Help is available through Stack Overflow, a moderated mailing list, and the GitHub issue tracker.
Facts from Mockito's own pages
- Android
- The site says Mockito can be used on Android with Dexmaker. · site.mockito.org, 9 Oct 2026
- Android requirement
- The v5.23.0 release notes state that mockito-android tests require an Android P (API 28) or newer device or emulator. · github.com, 9 Oct 2026
- Argument matching
- Mockito supports flexible argument matching for verification and stubbing. · github.com, 9 Oct 2026
- Build tools
- The site gives Maven Central and Gradle dependency setup instructions and refers users to other build systems. · site.mockito.org, 9 Oct 2026
- Distribution
- The recommended installation method is adding the mockito-core dependency through a build system. · site.mockito.org, 9 Oct 2026
- Enterprise support
- The repository says commercial support and maintenance are available through a Tidelift subscription. · github.com, 9 Oct 2026
- Help
- The project points users to Stack Overflow, a moderated mailing list, and its GitHub issue tracker for help. · github.com, 9 Oct 2026
- Java requirement
- The repository says Mockito 5 requires Java 11. · github.com, 9 Oct 2026
- License
- The repository publishes Mockito under the MIT License. · github.com, 9 Oct 2026
- Mocking
- It can mock concrete classes as well as interfaces. · github.com, 9 Oct 2026
- Partial mocks
- Its spy feature invokes real methods while allowing them to be verified and stubbed. · site.mockito.org, 9 Oct 2026
- Purpose
- Mockito is a mocking framework for writing unit tests in Java. · site.mockito.org, 9 Oct 2026
- Security
- The repository links to a security policy. · github.com, 9 Oct 2026
- Spies and injection
- Its API includes spies for partial mocking and @InjectMocks for injecting mock or spy fields. · site.mockito.org, 9 Oct 2026
- Stubbing and verification
- Mockito lets developers stub behavior before execution and verify selected interactions afterward. · github.com, 9 Oct 2026
- Support
- The project directs users to its mailing list for questions and documentation feedback, and GitHub for bugs and feature requests. · site.mockito.org, 9 Oct 2026
- Training
- Mockito core engineers offer team training on test automation with mock objects, behavior-driven development, and maintainable tests. · site.mockito.org, 9 Oct 2026
- Use guidance
- The project advises against mocking types you do not own, value objects, or everything indiscriminately. · site.mockito.org, 9 Oct 2026
- Verification options
- It supports ordered verification, exact or minimum call counts, and flexible argument matching. · github.com, 9 Oct 2026
Where Mockito stands on Freedom251
- Unit Testing Frameworks#15 of 32
