kotlin-testing

Generate Kotest and MockK test code for Kotlin modules.

7|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/chenziyang110/spec-kit-plus --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/spec-kit-plus/tree/main/templates/passive-skills/kotlin-testing
Command: npx skills add https://github.com/chenziyang110/spec-kit-plus --skill kotlin-testing-chenziyang110

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you write and improve correct Kotlin test suites so failures are easier to diagnose and coverage improves without flaky behavior.

Core Features & Use Cases

  • Kotest-based testing: Create consistent unit and integration tests using Kotest styles (e.g., FunSpec, DescribeSpec).
  • MockK for Kotlin dependencies: Mock collaborators and verify interactions with a Kotlin-friendly DSL.
  • Coroutine test correctness: Use kotlinx-coroutines-test patterns for suspend functions and coroutine flows.
  • Property testing support: Add invariant checks via Kotest forAll/checkAll to catch edge cases early.
  • Practical guidance for Android/Ktor/Spring contexts: Support ActivityScenario for Android and appropriate strategies for different component types.

Quick Start

Ask the agent: "Write Kotest + MockK tests for the Kotlin module in src/main/kotlin, including coroutine tests if needed, and include edge and failure cases."

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?

Mock Kotlin dependencies in tests using MockK to mock collaborators and verify interactions. The generated tests apply MockK's Kotlin-friendly DSL alongside Kotest structures to ensure reliable dependency isolation.

What is the best way to test Kotlin suspend functions and coroutines?

Test Kotlin suspend functions and coroutines using deterministic runTest-based execution from kotlinx-coroutines-test. This approach ensures correct coroutine testing behavior without flaky results in your test suite.

Can I use property testing to check invariants in Kotlin?

Use property testing in Kotlin to check invariants by applying Kotest forAll and checkAll functions. This property testing support catches edge cases early by automatically generating and validating input data against defined invariants.

Does Kotest testing work for Android ActivityScenario and Ktor or Spring contexts?

Kotest testing works for Android ActivityScenario, Ktor, and Spring contexts by applying appropriate testing strategies for different component types. The generated tests follow practical guidance to support these specific platform environments.

Why are my Kotlin coroutine tests flaky and how do I fix them?

Flaky Kotlin coroutine tests are fixed by enforcing strict guardrails and deterministic runTest-based execution. This ensures correct suspend function testing behavior and eliminates timing inconsistencies in coroutine flows.