kotlin-testing

Generates and diagnoses Kotlin tests using Kotest, MockK, and coroutine test dispatchers.

Updated Jul 6, 2026
One-click install
npx skills add https://github.com/chenziyang110/launchdeck --skill kotlin-testing-chenziyang110
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: kotlin-testing
Source: https://github.com/chenziyang110/launchdeck/tree/main/.claude/skills/kotlin-testing
Command: npx skills add https://github.com/chenziyang110/launchdeck --skill kotlin-testing-chenziyang110

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reliable Kotlin tests requires choosing the right spec style, mocking strategy, and coroutine dispatcher, and mistakes lead to flaky or meaningless tests. This Skill provides a structured workflow for generating, fixing, and improving Kotlin test suites with Kotest and MockK. ## Core Features & Use Cases - Test Generation: Produces Kotest tests (FunSpec, DescribeSpec, StringSpec) with MockK mocking, property-based testing, and data-driven cases following a five-phase execution protocol. - Coroutine & Android Testing: Applies runTest with StandardTestDispatcher for suspend functions and ActivityScenario with Espresso for Android UI tests. - Failure Diagnosis & Coverage: Diagnoses flaky tests, configures JaCoCo coverage reports, PIT mutation testing, and GitHub Actions CI integration. - Use Case: Ask the agent to write tests for a Kotlin service class with a repository dependency, and it generates a FunSpec with MockK mocks, boundary cases, and the Gradle commands to run them. ## Quick Start Ask the agent to write Kotest unit tests with MockK mocks for a specific Kotlin class in your project.

Frequently Asked Questions about kotlin-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write Kotlin unit tests with Kotest and MockK?▼

Use a Kotest spec style like FunSpec for test structure and MockK for mocking dependencies with mockk<T>(), every, and verify blocks. Add kotest-runner-junit5 and mockk to your Gradle test dependencies and run tests with ./gradlew test.

How to test Kotlin coroutines and suspend functions?▼

Test suspend functions inside runTest { } from kotlinx-coroutines-test, never with runBlocking. Use StandardTestDispatcher or UnconfinedTestDispatcher and advanceTimeBy() to control virtual time instead of Thread.sleep().

Kotest vs JUnit 5 for Kotlin testing, which should I use?▼

Kotest offers Kotlin-native spec styles, property-based testing via forAll, and data-driven tests with withData. JUnit 5 with MockK is simpler and better suited for mixed Java/Kotlin projects that need JUnit compatibility.

Why are my Kotlin coroutine tests flaky?▼

Flakiness usually comes from Thread.sleep(), real dispatchers, or uncleared mocks. Replace sleeps with runTest and advanceTimeBy(), use test dispatchers, and call clearAllMocks() in afterTest to isolate state.

Can I test Android Activities with this approach?▼

Yes, use ActivityScenario with Espresso in the androidTest source set for UI tests, combined with StandardTestDispatcher for ViewModel coroutines. Add androidx.test core-ktx, espresso-core, and runner dependencies.

When should I not use this Kotlin testing workflow?▼

Avoid it for general Kotlin feature development without test context, Gradle build errors, or multiplatform setup tasks. It also stops and asks when no test framework exists or the code has zero testability.