kotlin-testing

Write Kotlin tests using Kotest spec styles and MockK mocking.

Updated Apr 2, 2026
One-click install
npx skills add https://github.com/richardnpaul/everything-vscode-copilot --skill kotlin-testing-richardnpaul
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-testing
Source: https://github.com/richardnpaul/everything-vscode-copilot/tree/main/.github/skills/kotlin-testing
Command: npx skills add https://github.com/richardnpaul/everything-vscode-copilot --skill kotlin-testing-richardnpaul

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Solves the challenge of writing reliable Kotlin tests by providing proven patterns with Kotest and MockK.

Core Features & Use Cases

  • Kotest spec styles: StringSpec, FunSpec, BehaviorSpec, DescribeSpec for flexible test organization
  • Mocking and coroutine testing: MockK for mocking, coEvery/coVerify for suspend functions, runTest for coroutine testing
  • TDD workflow and coverage: guides RED-GREEN-REFACTOR cycle, Kover for coverage, data-driven and property-based testing
  • Testing lifecycle and CI: before/after_spec setups, reusable fixtures, and CI integration guidance

Quick Start

Write a failing Kotlin test using a Kotest spec style, then implement just enough code to pass it and iteratively refactor.

Frequently Asked Questions about kotlin-testing

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

FAQPage Schema
How do I write reliable Kotlin tests for suspend functions using Kotest and MockK?

Kotlin coroutine testing uses MockK's coEvery and coVerify to mock suspend functions, combined with Kotest's runTest to execute reliable asynchronous test verification patterns.

What is the best way to structure a TDD workflow for Kotlin projects?

TDD workflow in Kotlin projects follows the RED-GREEN-REFACTOR cycle, writing a failing Kotest spec first, implementing minimal code to pass, then refactoring iteratively.

Can I use different Kotest spec styles to organize my Kotlin tests?

Kotest spec styles allow flexible Kotlin test organization through StringSpec, FunSpec, BehaviorSpec, and DescribeSpec, letting you match test structure to your project's specific domain language.

How do I measure Kotlin code coverage during CI integration?

Kotlin code coverage is measured using Kover, which integrates with your CI pipeline to report test coverage metrics and verify testing lifecycle requirements across Kotest spec executions.

Does Kotest support property-based and data-driven testing?

Kotest supports property-based and data-driven testing by providing built-in mechanisms for generating test data and verifying properties, ensuring broader input coverage during the RED-GREEN-REFACTOR cycle.

How do I set up reusable test fixtures and lifecycle hooks in Kotlin tests?

Kotlin test fixtures and lifecycle hooks are configured using Kotest's before_spec and after_spec setups, allowing you to define reusable test states and teardown logic across your test suite.