Kotlin Testing
Test Kotlin/Spring services with JUnit 5, MockK (incl. coEvery for suspend), kotlinx-coroutines-test, Reactor StepVerifier, and Testcontainers.
- Step 1
Structuring Tests with JUnit 5 and Kotlin
JUnit 5 plus Kotlin's backtick names turns tests into readable, self-documenting specifications.
Read lesson - Step 2
Parameterized & Nested Tests in JUnit 5
Stop copy-pasting near-identical test methods: drive one test with many inputs and group related cases into readable, nested behavior blocks.
Read lesson - Step 3
MockK Fundamentals: Stubbing, Verifying, and Capturing
Replace real collaborators with controllable test doubles so you can assert behavior, not implementation.
Read lesson - Step 4
MockK for Coroutines: coEvery, coVerify, Flow, and Static/Object Mocks
Stub and verify suspend functions and Flows the idiomatic way — coEvery and coVerify do for coroutines what every and verify do for blocking code.
Read lesson - Step 5
Testing Coroutines and Flows with kotlinx-coroutines-test
Bend time to your will: test suspending code deterministically with runTest, virtual time, and Flow.toList().
Read lesson - Step 6
Reactor StepVerifier: Testing Reactive Streams
Drive a Flux through an expectation script and assert exactly what flows, fails, and finishes — even fast-forwarding through delays.
Read lesson - Step 7
Testcontainers: Real Databases in Your Integration Tests
Stop mocking your database and start testing against a real one, spun up in seconds with Docker.
Read lesson - Step 8
Fakes vs Mocks: Choosing Your Test Doubles
Fakes prove behavior, mocks prove conversations — pick the double that matches what you're actually testing.
Read lesson