kotlin-testing

Implements Kotlin test suites with Kotest, MockK, coroutine testing, and Kover coverage.

Updated Mar 12, 2026
One-click install
npx skills add https://github.com/RavitejaKarra24/dotfiles --skill kotlin-testing-ravitejakarra24
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-testing
Source: https://github.com/RavitejaKarra24/dotfiles/tree/main/pi/.pi/agent/skills/kotlin-testing
Command: npx skills add https://github.com/RavitejaKarra24/dotfiles --skill kotlin-testing-ravitejakarra24

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing consistent, maintainable Kotlin tests is hard when teams mix frameworks, skip the TDD cycle, or struggle with coroutine and Flow testing. This Skill provides idiomatic patterns for Kotest specs, MockK mocking, property-based testing, and Kover coverage so tests follow a repeatable RED-GREEN-REFACTOR workflow. ## Core Features & Use Cases - Kotest spec styles and matchers: StringSpec, FunSpec, BehaviorSpec, and DescribeSpec templates with core and custom matchers for expressive assertions. - MockK and coroutine testing: Patterns for coEvery/coVerify, argument capture, spies, runTest, TestDispatcher, and Flow emission testing. - Property-based and data-driven tests: Kotest property testing with custom Arb generators and withData tables for input matrices. - Kover coverage and CI: Gradle Kover configuration with 80% verification thresholds plus GitHub Actions integration. - Use Case: When adding a new UserService to a Ktor backend, follow the TDD walkthrough to write a failing FunSpec with a mocked repository, implement the minimal code, then verify coverage with ./gradlew koverVerify. ## Quick Start Write a Kotest test for my Kotlin EmailValidator function following the TDD workflow, mocking dependencies with MockK and verifying coverage with Kover.

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 tests with Kotest and MockK?

Choose a Kotest spec style like FunSpec, create mocks with mockk<Repository>(), stub calls with every or coEvery for suspend functions, and assert with matchers like shouldBe. Verify interactions using verify or coVerify after invoking the code under test.

How to test Kotlin coroutines and suspend functions?

Wrap tests in runTest from kotlinx-coroutines-test, which provides a controlled virtual-time environment. Use StandardTestDispatcher with advanceTimeBy to control delays, and never use Thread.sleep in coroutine tests.

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

This Skill standardizes on Kotest for its expressive spec styles, rich matchers, and built-in property-based testing. The guidance explicitly recommends picking Kotest and not mixing testing frameworks within a project.

How do I measure Kotlin code coverage with Kover?

Apply the org.jetbrains.kotlinx.kover Gradle plugin, then run ./gradlew koverHtmlReport for reports and koverVerify to enforce thresholds. The Skill targets 80% minimum coverage with higher bars for critical business logic.

Why should I avoid mocking data classes in Kotlin tests?

Data classes are simple value holders, so use real instances as test fixtures instead of mocks. Reserve MockK for services, repositories, and other dependencies with behavior that needs isolation.

How do I test Kotlin Flows with debounce or delays?

Collect emissions inside runTest using toList or a launched collector, then use advanceTimeBy to move virtual time past debounce windows. Assert on the collected emissions after time advancement.