testing-kmp

Write and review Kotlin Multiplatform tests across clean architecture layers using Mokkery and kotlin.test.

Updated Sep 12, 2026
One-click install
npx skills add https://github.com/Vierco/citoVisionApp --skill testing-kmp-vierco
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: testing-kmp
Source: https://github.com/Vierco/citoVisionApp/tree/main/.claude/skills/testing-kmp
Command: npx skills add https://github.com/Vierco/citoVisionApp --skill testing-kmp-vierco

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Deciding what to mock, which test doubles to use, and how to structure tests across Domain, Application, Infrastructure, and Presentation layers in a Kotlin Multiplatform project is error-prone and inconsistent. This Skill applies the project's TESTING.md rules to each layer so every class gets the right kind of test with the right doubles. ## Core Features & Use Cases - Layer-specific test strategy: Domain gets pure unit tests without mocks, Application mocks Ports with Mokkery, Infrastructure uses Ktor MockEngine or in-memory Room, and Presentation tests ViewModels via StateFlow observation. - Enforced conventions: Given/When/Then pattern, kotlin.test assertions, runTest for suspend/Flow code, and test directory structure mirroring main. - Koin graph verification: checkModules()/verify() tests for the Composition layer before merging. - Use Case: When adding a new GetUserUseCase, generate a Mokkery-based unit test covering the success path and each typed Result.Failure variant, placed in the mirrored test path. ## Quick Start Ask the assistant to write the tests for a specific class or feature, indicating which architecture layer it belongs to.

Frequently Asked Questions about testing-kmp

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

FAQPage Schema
How do I test a UseCase in Kotlin Multiplatform?▼

Test a UseCase as a unit test by mocking its Port interfaces with Mokkery and wrapping the test in runTest from kotlinx-coroutines-test. Cover both the success path and each typed Result.Failure variant, following the Given/When/Then pattern.

What mocking library works for Kotlin Multiplatform commonTest?▼

Mokkery is the mocking library for commonTest because Mockito and MockK are not multiplatform. Use mock<T>(), every/everySuspend for stubbing, and verify/verifySuspend for call verification.

How do I test a Ktor client without hitting a real API?▼

Use Ktor's MockEngine to intercept requests and return canned responses with specific status codes and JSON bodies. This keeps Infrastructure integration tests deterministic and independent of network access.

Should I use runBlocking or runTest for coroutine tests?▼

Use runTest from kotlinx-coroutines-test, never runBlocking. runTest gives you control over the TestDispatcher, skips real delays, and keeps the suite fast and deterministic.

When should Domain layer tests use mocks?▼

Never. Domain tests are pure unit tests that pass data to business rules and check results. If a Domain class needs a mock, it likely has a dependency that violates clean architecture and should be reviewed.

How do I verify a Koin dependency graph before merging?▼

Write a Composition-layer test using Koin's checkModules() or verify() on your modules. This validates the whole dependency graph at once rather than testing each dependency individually.