kotlin-testing
Kotlin testing patterns with Kotest, MockK, coroutine testing, property-based testing, and Kover coverage. Follows TDD methodology with idiomatic Kotlin practices.
npx skills add mturac/everything-openai-codex --skill kotlin-testing --agent codex
Same command for any agent — swap --agent for claude-code, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Guides the user through Kotlin testing patterns and workflows using Kotest, MockK, coroutine testing, property-based testing, and Kover coverage, aligned with TDD methodology.
How it works
- Identify target code — Find the function, class, or module to test
- Write a Kotest spec — Choose a spec style (StringSpec, FunSpec, BehaviorSpec) matching the test scope
- Mock dependencies — Use MockK to isolate the unit under test
- Run tests (RED) — Verify the test fails with the expected error
- Implement code (GREEN) — Write minimal code to pass the test
- Refactor — Improve the implementation while keeping tests green
- Check coverage — Run
./gradlew koverHtmlReportand verify 80%+ coverage
When to use it
- 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
What it can touch
- Commands and tooling referenced:
Kotestspecs styles (StringSpec, FunSpec, BehaviorSpec, DescribeSpec) - MockK setup including coroutine mocking and argument capture
- TDD workflow steps RED/GREEN/REFACTOR with sample EmailValidator
- Kover coverage commands and checks
Caveats
- License terms and repository context are not detailed here beyond the included examples and configurations
- The material includes executable code samples and configuration commands that must be run in a Kotlin/Gradle project environment
# 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](#kotest-spec-styles) - **Mocking** — MockK setu
- When to Use
- How It Works
- Examples
- Quick Reference
- TDD Workflow for Kotlin
- Kotest Spec Styles
- Kotest Matchers
- MockK
- Coroutine Testing
- Property-Based Testing
- Data-Driven Testing
- Test Lifecycle and Fixtures
- Kover Coverage
- Ktor testApplication Testing
Run tests with coverage Verify coverage thresholds XML report for CI View HTML report (use the command for your OS) Run all tests Run specific test class Run specific test Run with verbose output Run with coverage Run detekt (static analysis)
What does the kotlin-testing skill do?
Kotlin testing patterns with Kotest, MockK, coroutine testing, property-based testing, and Kover coverage. Follows TDD methodology with idiomatic Kotlin practices.
How do I install it?
Run `npx skills add mturac/everything-openai-codex --skill kotlin-testing --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From mturac/everything-openai-codex, a repository with 84 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
