MCPcopy
hub / github.com/mockito/mockito

github.com/mockito/mockito @v5.23.0 sqlite

repository ↗ · DeepWiki ↗ · release v5.23.0 ↗
8,223 symbols 34,992 edges 993 files 936 documented · 11%
README

Mockito

Most popular mocking framework for Java

CI Coverage Status MIT License

Release Notes Maven Central Javadoc

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?

How to develop Mockito?

To build locally:

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

Extension points exported contracts — how you extend this code

ArgumentMatcher (Interface)
Allows creating customized argument matchers. This API was changed in Mockito 2.1.0 in an effort to decouple Mockito fro [11 …
mockito-core/src/main/java/org/mockito/ArgumentMatcher.java
TestInterface (Interface)
(no doc) [7 implementers]
mockito-integration-tests/inline-mocks-tests/src/test/java/org/mockitoinline/HierarchyPreInitializationTest.java
BaseRepository (Interface)
(no doc) [2 implementers]
mockito-extensions/mockito-junit-jupiter/src/test/java/org/mockitousage/GenericTypeMockTest.java
SomeInterface (Interface)
(no doc)
mockito-extensions/mockito-proxy/src/test/java/org/mockitoproxy/MocksTest.java
VerificationMode (Interface)
Allows verifying that certain behavior happened at least once / exact number of times / never. E.g: < [21 implementers]
mockito-core/src/main/java/org/mockito/verification/VerificationMode.java
TestSubInterface (Interface)
(no doc)
mockito-integration-tests/inline-mocks-tests/src/test/java/org/mockitoinline/HierarchyPreInitializationTest.java
Answer (Interface)
Generic interface to be used for configuring mock's answer. Answer specifies an action that is executed and a return val [32 …
mockito-core/src/main/java/org/mockito/stubbing/Answer.java
Stubber (Interface)
Allows to choose a method when stubbing in doThrow()|doAnswer()|doNothing()|doReturn() style Example: <pre class="co [6 …
mockito-core/src/main/java/org/mockito/stubbing/Stubber.java

Core symbols most depended-on inside this repo

verify
called by 1014
mockito-core/src/main/java/org/mockito/InOrder.java
simpleMethod
called by 946
mockito-core/src/testFixtures/java/org/mockitousage/IMethods.java
when
called by 752
mockito-core/src/main/java/org/mockito/stubbing/Stubber.java
thenReturn
called by 579
mockito-core/src/main/java/org/mockito/stubbing/OngoingStubbing.java
oneArg
called by 478
mockito-core/src/test/java/org/mockitousage/jls/JLS_15_12_2_5Test.java
add
called by 324
mockito-core/src/main/java/org/mockito/internal/verification/RegisteredInvocations.java
append
called by 291
mockito-core/src/main/java/org/mockito/internal/matchers/apachecommons/EqualsBuilder.java
getName
called by 280
mockito-core/src/main/java/org/mockito/internal/invocation/MockitoMethod.java

Shape

Method 6,407
Class 1,530
Interface 269
Enum 17

Languages

Java100%

Modules by API surface

mockito-core/src/testFixtures/java/org/mockitousage/IMethods.java93 symbols
mockito-core/src/main/java/org/mockito/internal/exceptions/Reporter.java90 symbols
mockito-core/src/testFixtures/java/org/mockitousage/MethodsImpl.java87 symbols
mockito-core/src/test/java/org/mockito/internal/matchers/apachecommons/EqualsBuilderTest.java84 symbols
mockito-core/src/test/java/org/mockito/internal/creation/bytebuddy/InlineDelegateByteBuddyMockMakerTest.java78 symbols
mockito-core/src/testFixtures/java/org/mockitoutil/ClassLoaders.java72 symbols
mockito-core/src/test/java/org/mockitousage/matchers/VarargsTest.java65 symbols
mockito-extensions/mockito-junit-jupiter/src/test/java/org/mockitousage/GenericTypeMockTest.java62 symbols
mockito-core/src/main/java/org/mockito/internal/util/reflection/GenericMetadataSupport.java61 symbols
mockito-core/src/test/java/org/mockitousage/constructor/CreatingMocksWithConstructorTest.java58 symbols
mockito-core/src/test/java/org/mockito/internal/util/reflection/GenericMetadataSupportTest.java55 symbols
mockito-core/src/main/java/org/mockito/BDDMockito.java50 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add mockito \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact