Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

mockito

> 测试质量
Open source

Most popular Mocking framework for unit tests written in Java

15.4K stars0 likes12 views
WebsiteGitHub

About

Most popular Mocking framework for unit tests written in Java

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:

bash
./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:

    bash
    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.

Issues· 494 open

View all issuesOpen on GitHub
  • #3824

    Update InvocationOnMock to expose the invocation count

    Updated Sep 28, 2026
  • #3868

    after() busy-spins for its whole duration once verification succeeds

    Updated Sep 27, 2026
  • #2851

    Please publish package signing keys

    Updated Sep 11, 2026
  • #3863

    5.23.0 is incompatible with mockk-android due to dispatcher.jar conflict

    Updated Sep 10, 2026
  • #3848

    @Retryable annotation over the method of Spring service breaks stubbing when @SpyBean applied

    Updated Aug 4, 2026
  • #3779

    Is Mockito compatible with JUnit 6?

    Updated Jun 29, 2026
  • #2694

    java.lang.NoClassDefFoundError with mockito 3.11+

    please contributeUpdated Jun 21, 2026
  • #1066

    @InjectMocks ignores @Mock's name of generic type

    injectionUpdated Jun 16, 2026
  • #3592

    Improvement request: Include toString() of custom DoNotMock annotations in DefaultDoNotMockEnforcer

    Updated May 29, 2026
  • #3745

    Add support for final mocks

    Updated May 26, 2026

> Tags

Javajavajava-librarymockmock-library

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
Category测试质量
PricingOpen source

> Related tools

J
Jest
JavaScript 测试框架
P
Playwright
现代端到端测试框架
E
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.