0Pricing
Kotlin Academy · Lesson

Coroutine Testing

Test suspend functions.

Why Coroutine Testing is Special

Coroutines run asynchronously and may use delays. Tests need controlled time and a way to wait for suspend functions to finish.

The kotlinx-coroutines-test library provides exactly this.

Adding the Test Library

Add the coroutines test artifact to your test dependencies.

dependencies {
    testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1")
}

All lessons in this course

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