0Pricing
Kotlin Academy · Lesson

Mocking with MockK

Mock dependencies.

What is MockK?

MockK is a mocking library built for Kotlin. It creates fake versions of dependencies so you can test a class in isolation.

  • First-class Kotlin support (objects, extensions, coroutines)
  • Readable DSL for stubbing and verifying

Adding MockK

Add MockK as a test dependency.

dependencies {
    testImplementation("io.mockk:mockk:1.13.11")
}

All lessons in this course

  1. Writing Tests with JUnit5
  2. Assertions
  3. Mocking with MockK
  4. Coroutine Testing
← Back to Kotlin Academy