Agent skill

Kotest

by jvm-skills in jvm-skills/jvm-skills

Write a new Kotlin test, or modernize an existing one, using Kotest matchers and idiomatic Kotlin test style — backticked names, apply/assertSoftly blocks, and existing object mothers and helpers.

Apache-2.0Auto-check passedMobile

Install Kotest

skills CLI
$ npx skills add jvm-skills/jvm-skills --skill kotest -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jvm-skills/jvm-skills kotest --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jvm-skills/jvm-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.junie/skills/kotest .claude/skills/kotest && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
kotest
GitHub stars
139
Token cost
~2.6k tokens
SKILL.md length
1,210 words
Files
4 (incl. references)
Skills in repo
16
Repo updated
First seen
Licence
Apache-2.0

At a glance

Write a new Kotlin test, or modernize an existing one, using Kotest matchers and idiomatic Kotlin test style — backticked names, apply/assertSoftly blocks, and existing object mothers and helpers.

  • Adding a test for behavior that does not yet have one
  • SKILL.md covers Non-negotiables, Step 1 — Pick the track, Create track and Modernize track, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Improving a Kotlin test that still uses JUnit assertions

What it does

Kotest is an agent skill from jvm-skills/jvm-skills. Write a new Kotlin test, or modernize an existing one, using Kotest matchers and idiomatic Kotlin test style — backticked names, apply/assertSoftly blocks, and existing object mothers and helpers. Use when adding a test for behavior that does not yet have one, or when improving a Kotlin test that still uses JUnit assertions or AssertJ chains. Assumes project test infrastructure exists; flag missing factories or helpers rather than building them here.

Its SKILL.md is about 2.6k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/idiomatic-patterns.md`, `references/kotest-matchers.md` and `references/project.md`).

It sits in Mobile, covering Android development and Unit testing. It works with Kotlin and JUnit. The licence is Apache-2.0.

When your agent uses it

  • Adding a test for behavior that does not yet have one
  • Improving a Kotlin test that still uses JUnit assertions

Example prompts

  • “/kotest”

What it can do on your machine

Read from SKILL.md and the folder at commit c6d477f. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Kotest loads about 2.6k tokens when it runs, and up to ~6.9k if it reads all its reference files. Until then it costs about 115 tokens; SKILL.md has 1,210 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~115
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~6.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from jvm-skills/jvm-skills at commit c6d477f, republished under its Apache-2.0 licence (© jvm-skills). 1,210 words, ~2,575 tokens.

Download SKILL.mdSave it as .claude/skills/kotest/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
kotest
description
Write a new Kotlin test, or modernize an existing one, using Kotest matchers and idiomatic Kotlin test style — backticked names, apply/assertSoftly blocks, and existing object mothers and helpers. Use when adding a test for behavior that does not yet have one, or when improving a Kotlin test that still uses JUnit assertions or AssertJ chains. Assumes project test infrastructure exists; flag missing factories or helpers rather than building them here.

Kotest

Produce one high-quality Kotlin test in idiomatic style with Kotest matchers.

Two tracks, one skill:

  • Create — write a new test for described behavior.
  • Modernize — rewrite an existing Kotlin test to Kotest + idiomatic style.

Pick the track at step 1 based on inputs. The rest of the skill is the same knowledge applied to either starting point.

Non-negotiables

  • Do not build broad new test infrastructure inside this skill. If a needed factory / helper / DSL is missing, add a minimal inline fallback and tell the user that extraction may be warranted separately.
  • Do not change production code to make a test easier, unless the user asks.
  • Modernize track only: preserve assertion semantics exactly. Order sensitivity, nullability, and exception types must not change.
  • Follow project overlay (references/project.md) if present — it overrides shared defaults. The overlay is where framework-specific context lives (base classes, test annotations, single-test command, factory locations).

Step 1 — Pick the track

  • Modernize if a specific Kotlin test file/class was named, or the user said "improve / rewrite / migrate / modernize this test".
  • Create if the user described a behavior to cover, or pointed at production code without an existing test.

If input is a Java test file, this skill does not port it. Suggest the user either (a) describe the behavior so we run the Create track, or (b) manually stage a skeleton Kotlin test for us to run the Modernize track on.

Once the track is picked, follow the corresponding procedure below.


Create track

1. Understand the behavior

Read the production code the test will exercise:

  • The class/method under test and its collaborators.
  • Any validation, exception branches, or ordering guarantees that shape assertions.
  • Existing tests nearby — use them as style reference and to avoid duplicating coverage.

If the behavior is ambiguous, ask the user before writing the test.

2. Scan for reusable infrastructure

Before writing, search for what to reuse:

  • Object-mother / factory functions (typically *ObjectMother.kt, TestData.kt).
  • Kotlin extensions on domain types (toDto(), Iterable<T>.names()).
  • Test helpers for setup/teardown or I/O wiring.
  • DSLs for object-graph assembly.
  • Project base classes for tests (see references/project.md overlay).

If required infra is missing, add a minimal inline fallback or stop and flag it to the user. Do not quietly grow shared infra here.

3. Write the class header
  • Pick the test base class or annotations indicated by the project overlay. If there is no overlay, use a plain class with collaborators wired via constructor parameters.
  • Follow references/idiomatic-patterns.md for collaborator wiring and naming.
4. Write each test method

For each scenario:

  1. Name — backticked sentence: `should reject duplicate tag names`().
  2. Arrange — call existing factories; pass only arguments that matter.
  3. Act — invoke the behavior.
  4. Assert — Kotest matchers (references/kotest-matchers.md).

Assertion style:

  • Scalar: actual shouldBe expected.
  • Non-null: value.shouldNotBeNull() (smart-casts).
  • Collection sizing: list shouldHaveSize n.
  • Ordered: list shouldContainInOrder listOf(...).
  • Any-order: list shouldContainAllInAnyOrder listOf(...).
  • Field projection: items.map { it.name } shouldContainInOrder listOf(...).
  • Exceptions: shouldThrow<X> { ... }.message.shouldContain("...").
  • Multiple fields on one object: result.apply { ... }.
  • Several related checks reporting together: assertSoftly { ... }.

Each assertion must add independent semantic coverage. Do not restate fields already proven by a full-object equality. Do not wrap conditions in assertTrue — use a matcher that describes what the condition means.

5. Run the focused test

Use the single-test command defined in the project overlay. If none is specified, the project's usual test runner with a class-name filter is the right default.

If it fails: first confirm the assertion is correct for the behavior. A green test with the wrong assertion is worse than a red one. If production code is wrong, flag to the user — do not weaken the test.

6. Report
  • New file path.
  • Which existing infrastructure was reused.
  • Any inline fallbacks added (and whether shared extraction is warranted).
  • Scenarios covered / intentionally out of scope.
  • Exact verification command.

Modernize track

1. Read the source test

Record the existing:

  • Test framework hooks and annotations — preserve them verbatim.
  • Collaborator wiring style (fields vs constructor).
  • Any setup/teardown behavior.

These must not drift during modernization. Changing them silently is a bug.

2. Scan for reusable infrastructure

Same scan as the Create track. Existing factories / extensions / helpers are almost always underused in pre-Kotest tests — swap them in during this pass.

3. Modernize structure first, style second

Work in this order — the class must compile between each step:

  1. Switch mutable collaborator fields to constructor parameters where the test framework allows it. Keep lateinit var for fields that a framework mechanism requires (consult project overlay).
  2. Rename camelCase test methods to backticked sentences, preserving intent: shouldCreateTalk → `should create talk`.
  3. Leave assertions untouched for now. Only after compilation is clean, move on to the assertion rewrite.
Show full SKILL.md (452 more words)Show less
4. Rewrite assertions to Kotest matchers

Apply the rewrite tables in references/kotest-matchers.md. Key rules:

  • assertEquals(expected, actual) → actual shouldBe expected
  • assertNotNull(v) → v.shouldNotBeNull()
  • assertNull(v) → v.shouldBeNull()
  • assertEquals(n, list.size) → list shouldHaveSize n
  • assertTrue("x" in msg) → msg shouldContain "x"
  • assertThrows<X> { ... } → shouldThrow<X> { ... }
  • assertThat(x).isNotNull() → x.shouldNotBeNull()
  • assertThat(list).containsExactly(...) → list shouldContainInOrder listOf(...)
  • assertThat(list).containsExactlyInAnyOrder(...) → list shouldContainAllInAnyOrder listOf(...)
  • assertThat(items).extracting("name")... → items.map { it.name } shouldContain...
  • assertThatThrownBy { ... }.isInstanceOf(X::class.java).hasMessageContaining("y") → shouldThrow<X> { ... }.message.shouldContain("y")

Do not translate long AssertJ chains 1:1. Prefer explicit property assertions with apply { }.

5. Apply idiomatic blocks

For multiple field checks on one result, group with result.apply { ... } (references/idiomatic-patterns.md). Wrap in assertSoftly { ... } when all failures should be reported together. Don't wrap sequential dependent assertions in assertSoftly — earlier failures should stop the test there.

6. Simplify factory calls

Revisit DTO/entity construction:

  • Prefer zero-arg when defaults suffice: createSpeakerRequest().
  • Pass only assertion-relevant or uniqueness-critical arguments.
  • Do not restate default values just because the pre-modernization test spelled them out.

If the test hand-constructs objects and no factory exists, leave the construction inline. Do not create factories inside this skill — flag it to the user as a follow-up.

7. Remove redundant assertions

If a full-object equality already proves a field, drop the per-field check. Keep only assertions that add independent semantic coverage (ordering, exception details, nullability, values not otherwise covered).

8. Clean up imports

Remove:

  • org.assertj.core.api.Assertions.*
  • org.junit.jupiter.api.Assertions.*
  • Helpers that are no longer referenced.

Add the Kotest imports listed in references/kotest-matchers.md.

9. Run the focused test

Use the single-test command defined in the project overlay.

Iterate until green. Common causes of failure:

  • Order-sensitive matcher where an any-order matcher was needed, or vice versa.
  • Nullability mismatch between original Java-sourced types and Kotlin non-null types.
  • Missing Kotest matcher import.
  • Backticked name not escaped properly.
10. Report
  • File modernized.
  • Track taken (Modernize).
  • What changed at the structure level (wiring, naming).
  • Which existing infrastructure was newly adopted.
  • Semantics-sensitive decisions (ordering / exceptions / nullability).
  • Exact verification command.

Common pitfalls (both tracks)

  • Hand-building DTOs when a factory exists: scan for create*Request, *Dto.toEntity(), etc. before constructing manually.
  • Restating factory defaults: if the factory defaults email = "ada@example.com", do not re-pass it named-argument-style.
  • assertTrue(cond) wrappers: always replace with a specific matcher.
  • Assertion inflation: adding field-level checks that duplicate what a full-object equality already proves.
  • Wrong assertSoftly scope: it is for "report all related failures together", not for sequential dependent assertions.
  • Coroutine tests without runTest: suspend functions must run inside runTest { ... } (or the project's test-dispatcher wrapper).
  • Silently dropping framework hooks (Modernize track): setup/teardown annotations, transaction boundaries, and active profiles must carry over verbatim. Dropping them can cause intermittent pollution that only fails under certain run orders.

Project overlay

If references/project.md exists in this skill's directory after install, it overrides the shared defaults. This is where framework-specific context belongs (e.g. Spring Boot test types, base classes, single-test command, mocking library, factory locations). The skill itself stays framework-neutral.

© jvm-skills, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in .junie/skills/kotest of jvm-skills/jvm-skills.

  • SKILL.md
  • references/idiomatic-patterns.md
  • references/kotest-matchers.md
  • references/project.md

Open the folder on GitHubat commit c6d477f

Compare with similar skills

Kotest next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Kotest compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Kotest this skilljvm-skills/jvm-skills139—~2.6kAutomated safety check: PassApache-2.0
Kotlin Tooling Java To KotlinJetBrains/skills3663 repos~1.4kAutomated safety check: PassApache-2.0
Mps TestsJetBrains/MPS1.7k—~3kAutomated safety check: PassApache-2.0
Writing Tests With Kotlin Testskydoves/android-testing-skills334—~4.2kAutomated safety check: PassApache-2.0
Jvm Helpershepherdjerred/monorepo112—~1.9kAutomated safety check: PassGPL-3.0
Native Testing Strategybladeofgod/flutter-ai-harness116—~345Automated safety check: PassMIT

Similar skills

  • Official

    A skill your agent uses when converting Java source files to idiomatic Kotlin, when user mentions "java to kotlin", "j2k", "convert java", "migrate java to kotlin", or when working with .java files…

    366 GitHub starsUsed in 3 repos~1.4k tokens
    MobileAuto-check passed
  • Mps Tests

    JetBrains/MPS

    Official

    A skill your agent uses when writing or modifying tests inside MPS @tests models — NodesTestCase (typesystem, constraints, scopes, dataflow, generator output), EditorTestCase (intentions, actions…

    1.7k GitHub stars~3k tokensUpdated yesterday
    MobileAuto-check passed
  • Writing Tests With Kotlin Test

    skydoves/android-testing-skills

    A skill your agent uses to write tests with the kotlin.test library — the multiplatform assertion + annotation API that compiles the same in commonTest and on the JVM (JUnit4 or JUnit5), Android…

    334 GitHub stars~4.2k tokensUpdated 4 mo ago
    MobileAuto-check passed
  • Jvm Helper

    shepherdjerred/monorepo

    Current Java, Kotlin, Gradle, Maven, JUnit, JVM diagnostics, packaging, and performance guidance.

    112 GitHub stars~1.9k tokensUpdated yesterday
    MobileAuto-check passed
  • Native Testing Strategy

    bladeofgod/flutter-ai-harness

    适用:设计或审查 Kotlin/Swift 原生模块、Bridge Adapter、Host 编译、模拟器/设备和系统能力验证。不适用:纯 Dart/Flutter 测试或用 Fake 代替相机和权限真机验证。触发词:JUnit、XCTest、Robolectric、instrumented test、Swift Testing、Framework Fake、Gradle…

    116 GitHub stars~345 tokensUpdated 1 mo ago
    MobileAuto-check passed
  • Improve Code Coverage

    alexvanyo/composelife

    Helps increment code coverage in this Kotlin Multiplatform project.

    267 GitHub stars~1.1k tokensUpdated today
    MobileAuto-check passed

More from jvm-skills/jvm-skills

All 16 skills in this repo
  • Mutation Testing

    jvm-skills/jvm-skills

    Bootstrap pitest via the info.solidsoft.pitest Gradle plugin with Kotlin-sane defaults, run mutation tests scoped to changed classes, interpret surviving mutants from mutations.xml, triage…

    139 GitHub stars~6.7k tokensUpdated 1 mo ago
    Auto-check passed
  • Ralph Coverage

    jvm-skills/jvm-skills

    Run Ralph in coverage mode — iteratively write tests for untested classes until coverage targets are met.

    139 GitHub stars~683 tokensUpdated 1 mo ago
    Auto-check passed
  • Skill Scout

    jvm-skills/jvm-skills

    Run the skill-scout loop — scan the next batch of unscanned JVM-conference rosters for speaker-created AI skills and apply results to the CSV store via the overnight Workflow.

    139 GitHub stars~727 tokensUpdated 1 mo ago
    Auto-check passed
  • Spec

    jvm-skills/jvm-skills

    Generate a feature spec with user stories directly from conversation context and codebase exploration — no interview needed.

    139 GitHub stars~832 tokensUpdated 1 mo ago
    Auto-check passed
  • UI Review

    jvm-skills/jvm-skills

    Verify UI/UX by running Playwright tests and reviewing screenshots.

    139 GitHub stars~545 tokensUpdated 1 mo ago
    Auto-check passed
  • Voice

    jvm-skills/jvm-skills

    Make prose sound like Thomas, not like a generic technical writer.

    139 GitHub stars~592 tokensUpdated 1 mo ago
    Auto-check passed

Works with

Categories

Questions about Kotest

What does Kotest do?

Write a new Kotlin test, or modernize an existing one, using Kotest matchers and idiomatic Kotlin test style — backticked names, apply/assertSoftly blocks, and existing object mothers and helpers. Kotest is an agent skill from jvm-skills/jvm-skills. Write a new Kotlin test, or modernize an existing one, using Kotest matchers and idiomatic Kotlin test style — backticked names, apply/assertSoftly blocks, and existing object mothers and helpers.

When should I use Kotest?

Kotest fits situations like: adding a test for behavior that does not yet have one; improving a Kotlin test that still uses JUnit assertions.

How do I install Kotest in Claude Code?

Run `npx skills add jvm-skills/jvm-skills --skill kotest -a claude-code`. Or copy the skill folder (.junie/skills/kotest in jvm-skills/jvm-skills) into .claude/skills/kotest in your project. Claude Code loads it when a task matches its description.

How do I install Kotest in Codex?

Run `npx skills add jvm-skills/jvm-skills --skill kotest -a codex`. Or copy the skill folder (.junie/skills/kotest in jvm-skills/jvm-skills) into .agents/skills/kotest in your project. Codex loads it when a task matches its description.

Can I use Kotest in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jvm-skills/jvm-skills --skill kotest -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/kotest, .gemini/skills/kotest, .github/skills/kotest and .opencode/skills/kotest in your project.

What does Kotest need to run?

SKILL.md names no scripts, command-line tools or credentials: Kotest is instructions for the agent only.

Does Kotest access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Kotest safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Kotest use?

Kotest is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Kotest use?

About 2.6k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.3k tokens, read only when the agent opens those files.

What are the alternatives to Kotest?

Skills that share tags, products or a category with Kotest: Kotlin Tooling Java To Kotlin (JetBrains/skills, 366 stars), Mps Tests (JetBrains/MPS, 1.7k stars), Writing Tests With Kotlin Test (skydoves/android-testing-skills, 334 stars) and Jvm Helper (shepherdjerred/monorepo, 112 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Kotest?

jvm-skills (a GitHub organization) maintains it in jvm-skills/jvm-skills, which has 139 GitHub stars. The repository holds 16 skills in this directory. The repository was last updated on August 31, 2026.

Source: jvm-skills/jvm-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.