Skip to content
SPECIFICTION
Get listed

MockK

mockk.io

WindowsmacOSLinuxAndroid
Visit mockk.io
Spec score 7.3 #28 of 32 in Unit Testing Frameworks

Spec sheet

Purpose
MockK is a mocking library for Kotlin.Read 11 Oct 2026 · mockk.io
Support
The project directs users to Stack Overflow or Gitter for questions and GitHub for bug reports.Read 11 Oct 2026 · mockk.io
License
The linked public GitHub repository identifies its license as Apache-2.0.Read 4 Oct 2026 · github.com
BDD
Optional BDD-style aliases include given, then, coGiven, and coThen.Read 4 Oct 2026 · mockk.io
BDD aliases
MockK provides optional BDD style aliases such as given and then.Read 11 Oct 2026 · mockk.io
Coroutines
MockK supports stubbing and verifying suspend functions with coroutine-specific APIs, with the kotlinx-coroutines-core dependency.Read 11 Oct 2026 · mockk.io
Distribution
The setup guide lists JVM, Android unit-test and Android instrumented-test dependency artifacts.Read 11 Oct 2026 · mockk.io
Framework integrations
The site points to SpringMockK for Spring support and quarkus-mockk for mocking Quarkus beans.Read 11 Oct 2026 · mockk.io
Framework support
The site links to SpringMockK and Quarkus-MockK support.Read 4 Oct 2026 · mockk.io
JDK caveats
The documentation notes dynamic Java agent warnings on JDK 21+ and says spies or mockkStatic may not work on JDK 16+.Read 11 Oct 2026 · mockk.io
Known issue
The site notes that spies and mockkStatic may fail on JDK 16 and later with access exceptions.Read 4 Oct 2026 · mockk.io
Known limitation
Inline functions cannot be mocked, according to the known issues section.Read 11 Oct 2026 · mockk.io
Kotlin compatibility
The site says MockK supports Kotlin 1.4 and higher from version 1.13.0.Read 4 Oct 2026 · mockk.io
Kotlin support
The site says MockK supports Kotlin 1.4 and higher from MockK version 1.13.0.Read 11 Oct 2026 · mockk.io
Mock behavior
Mocks are strict by default and require behavior to be provided.Read 4 Oct 2026 · mockk.io
Mocking features
The feature guide covers spies, relaxed and partial mocks, object, class, enum and constructor mocks, argument matching, and call verification.Read 11 Oct 2026 · mockk.io
Security-related feature
Restricted Mocking can prevent mocking classes considered problematic for reliable tests, and the documentation lists several Java system and collection classes restricted by default.Read 4 Oct 2026 · mockk.io
Setup
The documentation shows adding MockK as a test dependency with Gradle or Maven.Read 11 Oct 2026 · mockk.io
Strict mocks
Mocks are strict by default, so users need to provide behavior for them.Read 11 Oct 2026 · mockk.io
Suspending spy caveat
The site warns that using a spy with a suspending function can produce unexpected test results.Read 11 Oct 2026 · mockk.io
Test integrations
The documentation describes JUnit 4 and JUnit 5 support, including a JUnit 5 extension for initializing mocks.Read 11 Oct 2026 · mockk.io

Where Specifiction places it

Alternatives to MockKAll alternatives →