mockito/mockito-kotlin
mockito/mockito-kotlin has 3,160 GitHub stars and 209 forks. GitHot measured 0 stars in 24 hours and 0 in 7 days. Last checked 2026-11-09 16:42 UTC. Last push 2026-10-14.
Using Mockito with Kotlin
Measured star growth
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalMockito-Kotlin
A small library that provides helper functions to work with Mockito in Kotlin.
Install
Mockito-Kotlin is available on Maven Central.
For Gradle users, add the following to your build file, replacing x.x.x with the latest version:
build.gradle:
testImplementation "org.mockito.kotlin:mockito-kotlin:x.x.x"
build.gradle.kts:
testImplementation("org.mockito.kotlin:mockito-kotlin:x.x.x")
Example
A test using Mockito-Kotlin typically looks like the following:
@Test
fun doAction_doesSomething(){
/* Given */
val mock = mock<MyClass> {
on { getText() } doReturn "text"
}
val classUnderTest = ClassUnderTest(mock)
/* When */
classUnderTest.doAction()
/* Then */
verify(mock).doSomething(any())
}
For more info and samples, see the Wiki.
Android Support
See the Android Support wiki.
Building
Mockito-Kotlin is built with Gradle.
./gradlew buildbuilds and tests the project./gradlew publishToMavenLocalinstalls the maven artifacts in your local repository./gradlew checkruns the test suite (See Testing below)
Versioning
Mockito-Kotlin roughly follows SEMVER
Testing
Mockito-Kotlin's test suite is located in a separate tests module,
to allow running the tests using several Kotlin versions whilst still
keeping the base module at a recent version.
./gradlew checkruns the checks including tests.
Usually it is enough to test only using the default Kotlin versions;
CI will test against multiple versions.
If you want to test using a different Kotlin version locally,
add the -PtestKotlinVersion=1.2.3 argument to the Gradle invocation while running the tests.
Acknowledgements
mockito-kotlin was created and developed by nhaarman@ after which the repository was integrated into the official Mockito GitHub organization.
We would like to thank Niek for the original idea and extensive work plus support that went into mockito-kotlin.
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
561,398 starspublic-apis/public-apis
A collective list of free APIs
497,679 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
447,495 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,261 stars