
About MockK
MockK is a mocking library built for Kotlin code. It supports features that many Java mocking tools lack, such as named parameters, object mocks and coroutines.
What it does
You create mocks with a Kotlin DSL and define behaviour with every and returns. It can mock object declarations and extension functions, and it provides verify and confirmVerified checks to make sure no unexpected calls were made. Coroutine versions of the same functions are available for suspending code.
Key features
- Kotlin DSL for mocks and behaviour
- Coroutine mocks with coEvery and coVerify
- Object and extension function mocks
- Separate packages for Android unit and instrumented tests
Who it's for
Kotlin and Android developers who want a mocking tool written for the language, and teams with Spring or Quarkus projects that need bean mocks.
Pricing and good to know
MockK is Apache-2.0 licensed and free to use. It supports Kotlin 1.4 and higher. The known issues list includes inline functions, which cannot be mocked, and a warning about a Java agent on JDK 21 and later. The GitHub repository has about 5.8k stars.
Highlights
- Mock Kotlin classes and objects with a DSL
- Coroutine support with coEvery and coVerify
- Mock extension functions
- Packages for Android unit and instrumented tests












