Agent skill · software engineering · affaan-m
kotlin-testing
Kotlin testing patterns with Kotest, MockK, coroutine testing, property-based testing, and Kover coverage. Follows TDD methodology with idiomatic Kotlin practices. Use when writing Kotlin tests with Kotest or MockK, or testing coroutines and checking coverage.
Why this skill is useful
Provides specific Kotlin testing patterns and TDD workflows that the AI wouldn't reliably generate on its own.
What it needs
Requires gradle installed locally. About 8k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.
What this skill does
Kotlin Testing Patterns Comprehensive Kotlin testing patterns for writing reliable, maintainable tests following TDD methodology with Kotest and MockK. When to Use Writing new Kotlin functions or classes Adding test coverage to existing Kotlin code Implementing property-based tests Following TDD workflow in Kotlin projects Configuring Kover for code coverage How It Works 1. Identify target code — Find the function, class, or module to test 2. Write a Kotest spec — Choose a spec style (StringSpec, FunSpec, BehaviorSpec) matching the test scope 3. Mock dependencies — Use MockK to isolate the unit under test 4. Run tests (RED) — Verify the test fails with the expected error 5. Implement code (GREEN) — Write minimal code to pass the test 6. Refactor — Improve the implementation while keeping tests green 7. Check coverage — Run ./gradlew koverHtmlReport and verify 80%+ coverage Examples The following sections contain detailed, runnable examples for each testing pattern: Quick Reference Kotest specs — StringSpec, FunSpec, BehaviorSpec, DescribeSpec examples in Kotest Spec Styles Mocking — MockK setup, coroutine mocking, argument capture in MockK TDD walkthrough — Full RED/GREEN/REFACTOR cycle with EmailValidator in TDD Workflow for Kotlin Coverage — Kover configuration and commands in Kover Coverage Ktor testing — testApplication setup in Ktor testApplication Testing TDD Workflow for Kotlin The RED-GREEN-REFACTOR Cycle Step-by-Step TDD in Kotlin Kotest Spec Styles StringSpec (Simplest) FunSpec (JUnit-like) BehaviorSpec (BDD Style) DescribeSpec (RSpec Style) Kotest Matchers Core Matchers Custom Matchers MockK Basic Mocking Coroutine Mocking Argument Capture Spy and Partial Mocking Coroutine Testing runTest for Suspend Functions Testing Flows TestDispatcher Property-Based Testing Kotest Property Testing Custom Generators Data-Driven Testing withData in Kotest Test Lifecycle and Fixtures BeforeTest / AfterTest Kotest Extensions Kover Coverage Gradle Configuration Coverage Co …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills affaan-m/kotlin-testing--a91a68