mockito /mockito
Most popular Mocking framework for unit tests written in Java
★ 15,448⑂ 2,684👁 407⑃ 2,063● 1,811▤ 227
-1
Daily
15,448
stars
2,684
forks
407
watchers
2,063
prs
1,811
issues
227
releases
README
Most popular mocking framework for Java
Current version is 5.x
Still on Mockito 1.x? See what's new in Mockito 2!
Mockito 3 does not introduce any breaking API changes, but now requires Java 8 over Java 6 for Mockito 2.
Mockito 4 removes deprecated API.
Mockito 5 switches the default mockmaker to mockito-inline, and now requires Java 11.
Only one major version is supported at a time, and changes are not backported to older versions.
Mockito for enterprise
Available as part of the Tidelift Subscription.
The maintainers of org.mockito:mockito-core and thousands of other packages are working with Tidelift to deliver
commercial support and maintenance for the open source dependencies you use to build your applications. Save time,
reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use.
Learn more.
Development
Mockito publishes every change as a -SNAPSHOT version to a public Sonatype repository. Roughly once a month, we
publish a new minor or patch version to Maven Central. For release automation we use
Shipkit library, Gradle Nexus Publish Plugin.
Fully automated releases are awesome, and you should do that for your libraries, too!
See the latest release notes
and latest documentation. Docs in
javadoc.io are available 24h after release. Read also
about semantic versioning in Mockito.
Older 1.x and 2.x releases are available in
Central Repository
and javadoc.io (documentation).
More information
All you want to know about Mockito is hosted at The Mockito Site which is Open Source and likes pull requests, too.
Want to contribute? Take a look at the Contributing Guide.
Enjoy Mockito!
Need help?
Search / Ask question on stackoverflow
Go to the mockito mailing-list (moderated)
Open a ticket in GitHub issue tracker
How to develop Mockito?
To build locally:
shell
./gradlew build
You can open in any IDE that support Gradle, e.g. IntelliJ IDEA, or Fleet.
For Eclipse, one may need to run ./gradlew eclipse before importing the project.
How to release new version?
1. Every change on the main development branch is released as -SNAPSHOT version to Sonatype snapshot repo
at https://s01.oss.sonatype.org/content/repositories/snapshots/org/mockito/mockito-core.
2. To release a non-snapshot version to Maven Central push an annotated tag, for example:
shell
git tag -a -m "Release 3.4.5" v3.4.5
git push origin v3.4.5
3. At the moment, you may not create releases from GitHub Web UI. Doing so will make the CI build fail because the
CI creates the changelog and posts to GitHub releases. We'll support this in the future.Top issues
#769Strictness in Mockito54 comments · 2016-11-19#2436mockito-inline on OpenJDK 17 fails to start due to ByteBuddy agent failure38 comments · 2021-09-26#1511Mockito-Android 2.23.0 fails transformClassesWithDexBuilderForDevelopDebugAndroidTest31 comments · 2018-10-06#978AttachNotSupportedException: no providers installed. When using mock-maker-inline extension and jmockit.jar is found in classpath on Windows.31 comments · 2017-03-06#1053Real method on mocked object is always called25 comments · 2017-04-28#3156Mockito doesn't initialise static constructors before instrumentation correctly24 comments · 2023-10-21#2142Mocked static methods are not available in other threads24 comments · 2020-12-13#1437Different mocks are used for @Mock and @InjectMock when using @TestInstance(TestInstance.Lifecycle.PER_CLASS) of jUnit522 comments · 2018-07-21
Discussions
#3782Difference between Mockito instrumentation and ByteBuddy instrumentation2 comments · 2026-01-07#3740Mockito assumptions1 comments · 2025-09-30#3717How to register more defaults globally in particular for Project Reactor2 comments · 2025-08-28#3639Mockito code evolution0 comments · 2025-04-16#3630Get error Byte Buddy agent is not initialized or unavailable when upgrade from Mockito 3.12.4 to 5.4.0, JDK11, bazel repository1 comments · 2025-03-31#3603Gradle plugin for Mockito agent configuration2 comments · 2025-03-03#3598Mocking Logger - Running individually OK - Running together fails1 comments · 2025-02-25#3596Helper maven plugin for Java agent warnings1 comments · 2025-02-23
Latest release
v5.24.0 v5.24.0 2026-09-23Changelog generated by Shipkit Changelog Gradle Plugin 5.24.0 - 2026-09-23 - 27 commit(s) by Andrei Solntsev, DragonFSKY, Hünkar Can Tunç, Joshua Selbo, M. Minot, Markus Gaisbauer, Mirko Alicastro, Vinod Kumar M ( codingkiddo ), dependabot[bot] - Fix Mockito docs for -javaagent flag with Gradle (3866) - Kotlin example for adding Mockito as an agent is incorrect (3864) - Bump graalvm/setup-graalvm from 1.6.3 to 1.6.6 (3862) - Bump gradle/actions from 6.2.0 to 6.3.0 (3852) - Bump gradle/actions from 5 to 6.2.0 (3851) - Preserve method parameters when clearing inline mocks (3847