writing-kotlin-tests

Installation
SKILL.md

Writing Kotlin Tests

Use this skill to choose the right test level first, then write compact contract-focused Kotlin tests.

Use kotlin.test APIs for test annotations and assertions. Use MockK when interaction matters. Do not use JUnit assertion or annotation APIs, Mockito, AssertJ, Hamcrest, Truth, or another assertion library unless an existing framework assertion requires it. For E2E JSON body checks, use jsonPath or parse JSON and assert fields with kotlin.test; Hamcrest matchers are allowed only inside an existing jsonPath assertion API.

Workflow

  1. Read the target code, nearby tests, build configuration, Kotlin version, platform, and source set before writing anything.
  2. Decide the lowest useful test level: unit, integration, or E2E.
  3. Load the matching reference only when needed:
  4. Identify the public contract and add the smallest useful test set.
  5. Avoid duplicate coverage across levels.
  6. Put unit and integration tests in the module and source set that own the behavior.
  7. Run the narrowest relevant test command first, then broader tests when risk justifies it.
Installs
11
Repository
dungsil/skills
First Seen
Jul 22, 2026