OSS Tanbou

mock, stub, and verify Kotlin collaborators with coroutine and Android support

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
5,760
Primary language
Kotlin
License
Apache-2.0
Repository last updated
Sep 29, 2026
On this page

Overview

MockK is a mocking library for Kotlin. Tests create doubles with mockk, define behavior with every, and verify interactions with verify. It also provides coroutine APIs, annotations, JUnit integration, and Android-specific artifacts.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Define strict mock behavior and verify interactions

Create a mock with mockk<T>(), stub behavior with every { ... } returns ..., and verify calls with verify { ... }. Mocks are strict by default, making unstubbed interactions explicit.

Sources: [2]

Use coroutine, annotation, and Android-specific APIs

coEvery and coVerify cover suspend functions, annotations such as @MockK integrate with JUnit helpers, and dedicated artifacts support Android unit and instrumented tests.

Sources: [2]

Best fit

Fits Kotlin unit tests that need explicit interaction verification

It is useful when services, repositories, and other collaborators should be replaced with test doubles and verified by arguments, calls, or behavior.

Sources: [2]

Before adoption

Inline functions and some JDK access patterns are limited

The README lists inline functions as non-mockable and notes access issues for some static or spy scenarios on JDK 16+, plus dynamic-agent warnings on JDK 21+.

Sources: [2]

Be cautious with spies around suspending functions

The documented known issues include unexpected results when combining spies with suspending functions. Prefer explicit mocks for coroutine tests and validate any spy-based case carefully.

Sources: [2]

Official sources

  1. [1]mockk/mockk repository(2026-09-30)
  2. [2]MockK v1.14.11 README(2026-09-30)
  3. [3]MockK v1.14.11 gradle.properties(2026-09-30)
  4. [4]MockK v1.14.11 release(2026-09-30)
  5. [5]MockK Apache 2.0 license(2026-09-30)
Supplemental curator note

MockK 1.14.11 is a Kotlin mocking library with strict mocks by default. every defines behavior and verify checks interactions, with coEvery/coVerify for coroutines and Android-specific artifacts available. Inline functions and some JVM access scenarios remain constrained.

Try it in 3 steps

  1. 1

    Add MockK 1.14.11

    Add the stable release as a Kotlin JVM test dependency. Use mockk-android when the Android-specific artifact is required.

    testImplementation("io.mockk:mockk:1.14.11")
  2. 2

    Stub one behavior

    Create a strict mock and define only the interaction needed by the test.

    val service = mockk<Service>() every { service.load() } returns "ok"
  3. 3

    Verify the call

    Execute the method and verify that the expected interaction occurred.

    service.load() verify { service.load() }
Check the official README

Growth

Growth trends · Last 30 days

5,760 Stars

Trend data is still being collected.

Built with

Categories and tags

GitHub data

GitHub dataView detailed GitHub data

GitHub Topics

  • argument-matchers
  • chain-calls
  • hacktoberfest
  • kotlin
  • matcher
  • mock
  • mocking-framework
  • tdd
  • testing
  • verification
Stars
5,760
Forks
420
Watchers
56
Open issues
296
Owner type
Organization
Primary language
Kotlin
License
Apache-2.0
Repository last updated
Sep 29, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?