Skip to content
CAI
Software that uses CAICheck a score

mockito/mockito-kotlin

60.0

Adequate · 14 November 2026

3k

lines of production code

Kotlin

primary language

5

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

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 cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 61 → 60 (-0.5)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.

Lenses

  • Code Health 96 → 95 (-0.7)
  • Architecture 100 → 100 (+0.0)
  • Maturity 51 → 51 (+0.0)
  • Readiness 55 → 50 (-5.0)
  • Security 79 → 79 (+0.0)

Resolved (53)

  • Duplicated block (16–17 lines × 2) (mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mocking.kt)
  • Off-boarding risk: anonymized user #1
  • Outdated (compile): com.fasterxml.jackson.core:jackson-annotations
  • Outdated (compile): com.fasterxml.jackson.core:jackson-core
  • Outdated (compile): com.fasterxml.jackson.core:jackson-databind
  • Outdated (compile): com.fasterxml.jackson.dataformat:jackson-dataformat-xml
  • Outdated (compile): com.fasterxml.jackson.module:jackson-module-jaxb-annotations
  • Outdated (compile): com.fasterxml.jackson.module:jackson-module-kotlin
  • Outdated (compile): com.fasterxml.jackson:jackson-bom
  • Outdated (compile): com.fasterxml.woodstox:woodstox-core
  • Outdated (compile): io.reactivex.rxjava2:rxjava
  • Outdated (compile): jakarta.activation:jakarta.activation-api
  • Outdated (compile): jakarta.xml.bind:jakarta.xml.bind-api
  • Outdated (compile): net.bytebuddy:byte-buddy
  • Outdated (compile): net.bytebuddy:byte-buddy-agent
  • Outdated (compile): org.codehaus.woodstox:stax2-api
  • Outdated (compile): org.freemarker:freemarker
  • Outdated (compile): org.hamcrest:hamcrest-core
  • Outdated (compile): org.jetbrains.dokka:analysis-kotlin-descriptors
  • Outdated (compile): org.jetbrains.dokka:analysis-markdown
  • …and 33 more

New (4)

  • Dependency hygiene PARTLY measured — Maven/Gradle declarations read, no dependency graph resolved
  • Duplicated block (16–17 lines × 2) (mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mocking.kt)
  • Edited copy of a member (19 corresponding lines) (mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mocking.kt)
  • Off-boarding risk: anonymized user #1

Written by cca.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 14 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 5969d27280ea670520003c75776057b20f7f3dfb — the exact code this score is about.
  • Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-e1a3b69fc8ee.