mockito/mockito-kotlin
64.0
Adequate · 28 September 2026
5.3k
lines of production code
Kotlin
primary language
2
measurements over time
What this system is
This system is the Mockito-Kotlin library, which provides idiomatic Kotlin wrappers for the Mockito mocking framework. It enables Kotlin-native features such as stubbing and verifying suspend functions, handling value classes, and mocking Kotlin object singletons. The project also includes performance benchmarks against MockK and maintains a modernized Gradle build structure for publishing to Maven Central.
How it got here
2016 — Migration to official Mockito and modernization
5 changes.
The project migrated to the official Mockito organization, updating Maven coordinates and removing legacy Kotlin extension functions and their associated tests. This period involved a comprehensive modernization of the build system, including upgrades to Kotlin 2.1.20, Mockito 5.23.0, and Gradle 9.4.1, alongside the adoption of a multi-module structure and modern publishing workflows.
2018–2026 — Kotlin-first API and value class support
7 changes.
The project restructured its public API to prioritize idiomatic Kotlin patterns, introducing dedicated modules for stubbing, verification, and BDD-style mocking. Internal implementations were enhanced to robustly handle Kotlin-specific features such as value classes and suspend functions, ensuring compatibility with or without coroutine dependencies. This period also involved expanding test coverage for these new capabilities and establishing code formatting conventions.
Removals
Removal of legacy Kotlin extension functions and internal utilities
The library has removed several internal and extension functions from the \com.nhaarman.mockito\_kotlin\ package, including \Any.kt\ (which contained \any()\, \anyArray()\, and instance creation logic), \MatcherExtension.kt\ (containing \argThat\), \Mockito.kt\ (containing \mock\, \spy\, \whenever\, \verify\, \inOrder\, \eq\, and \isNull\), and \MockSettings.kt\. This change eliminates the custom Kotlin wrappers and internal helper methods that previously bridged Kotlin syntax with Mockito's Java API, likely to reduce maintenance overhead or align with newer Mockito Kotlin idioms.
mockito-kotlin/src/main/kotlin/com · high confidence
Behavioural changes
Added Spotless code formatting configuration
The build system now includes conventions for applying code formatting using Spotless with the ktfmt formatter. This change introduces a new library convention that applies the Spotless plugin and configures it to enforce Kotlin language style formatting, though the enforcement check is disabled by default to allow separate CI execution.
build-logic · high confidence
Enhanced support for Kotlin value classes and suspend functions
The internal implementation in the \org.mockito.kotlin.internal\ package has been expanded to better handle Kotlin-specific language features. New classes and utilities now provide robust support for value classes (including boxing, unboxing, and instance creation) and improve the handling of suspend functions via a coroutine-aware answer mechanism. Additionally, a safe run-blocking utility ensures compatibility with projects that do not include the kotlinx-coroutines-core library, preventing runtime errors when using suspending lambdas in a non-coroutine context.
mockito-kotlin/src/main/kotlin/org/mockito/kotlin/internal · high confidence
Migration to official Mockito organization and updated documentation
The project has moved to the official Mockito GitHub organization and updated its Maven coordinates to \org.mockito.kotlin:mockito-kotlin\. The README has been rewritten to reflect the new installation instructions via Maven Central, includes a modernized example using the \mock {}\ DSL, and adds sections for Android support and building. Additionally, Travis CI has been removed in favor of other CI mechanisms, and a new RELEASING.md guide documents the process for publishing to Sonatype snapshots and Maven Central.
(repo-wide) · high confidence
Mockito-Kotlin API restructured with Kotlin-first stubbing and verification
The library's public API has been reorganized into dedicated Kotlin-specific modules, introducing idiomatic stubbing via the \KStubbing\ class (enabling \stubbing { on { ... } doReturn ... }\ syntax), BDD-style \given\/\then\ wrappers with coroutine support, and Kotlin-aware argument matchers that handle value classes and suspend functions. Verification capabilities are expanded with \KInOrder\ for ordered checks on suspending and static methods, while \MockedObject\ provides combined mocking for Kotlin object singletons. Existing Java-centric entry points are preserved as aliases, but the new structure shifts the primary interaction model toward Kotlin-native patterns.
mockito-kotlin/src/main/kotlin/org/mockito/kotlin · high confidence
Test coverage
Added comparative benchmarks between Mockito-Kotlin and MockK; Added regression test for synchronous mock stubbing without coroutines; Added tests for BDDMockito Kotlin stubbing and coroutine answer handling; Expanded test coverage for Mockito-Kotlin features; Removed legacy test suite for matchers, mocking, and spying.
Dependencies
Upgrade Gradle wrapper to version 9.4.1
The Gradle wrapper has been upgraded from version 2.10 to 9.4.1. This change updates the distribution URL and includes a SHA-256 checksum for distribution integrity verification, along with a network timeout setting, ensuring that builds use the newer Gradle release and validating the downloaded binary.
gradle · high confidence
Upgrade to Kotlin 2.1.20 and Mockito 5.23.0 with modernized Gradle build
The project has been upgraded to Kotlin 2.1.20 and Mockito 5.23.0, moving from the legacy \buildscript\ plugin configuration to the modern \plugins {}\ block and adopting \jvmToolchain\ for Java version management. This change also introduces a multi-module build structure that separates tests into \tests\ and \no-coroutine-tests\ subprojects, adds a \benchmarks\ module for performance comparison against MockK, and configures publishing to Maven Central via the Gradle Nexus Publish Plugin.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 62 → 64 (+2.5)
- Rubric changed (rubric-2026.09.8 → rubric-2026.09.16) — scores are not directly comparable.
Lenses
- Code Health 100 → 100 (+0.0)
- Architecture 100 → 100 (+0.0)
- Maturity 59 → 59 (+0.0)
- Readiness 50 → 55 (+5.2)
- Security 72 → 72 (+0.0)
Resolved (3)
- Documentation: no installation or build instructions (README.md)
- Documentation: no usage examples (README.md)
- Off-boarding risk: anonymized user #1
New (2)
- Documentation: no architecture or design documentation (benchmarks/README.md)
- Off-boarding risk: anonymized user #1
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
mockito/mockito-kotlin was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 28 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 7a1f513e21b9bc0a65b282c3c065b26a7f900c43 — the exact code this score is about.
- Scored under rubric-2026.09.16 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-2d9048c36d26.