komust

A mutation-testing Gradle plugin for Kotlin/JVM, with reports that help developers and coding agents identify missing tests.

KotlinK2 compiler IRGradle pluginJVMMutation testing

v0.1.0-SNAPSHOT·github.com/MihaFriskovec/komust

Problem

Mutation testing tells you whether a test suite actually catches bugs by introducing small faults ("mutants") into the code and checking that a test fails. On the JVM, pitest is the standard tool — but it operates on bytecode and was built for Java, so against idiomatic Kotlin the compiler-generated code gets in the way. The traditional per-mutant recompile-and-rerun loop is also too slow to run inside the inner development loop.

Approach

komust is a Gradle plugin (id("io.komust")) that works at the K2 compiler IR level instead of on bytecode, so it sees Kotlin the way the compiler does.

  • Compile once, switch at runtime. Rather than recompiling per mutant, komust weaves every mutant into a single compilation and toggles them with a runtime guard. This collapses the dominant cost of a mutation-testing run.
  • Modified-files scope by default. It mutates only code changed against a git base ref, so feedback stays proportional to the size of the edit — ./gradlew mutationTest --all covers the whole project when you want it.
  • Coverage-mapped test selection. Per mutant, only the tests that cover the mutated line run.
  • Forked worker pool + incremental cache. Mutants execute in parallel with process isolation and hang-kill timeouts; results are reused when source, tests, and config are unchanged.
  • 14 mutation operators — 11 default, 3 experimental.
  • Reports for coding agents. survivors.json lists gaps where tests did not catch a mutation. Each entry includes a "write a test that does X" instruction sized for an agent's context window. report.json contains the full results.

Current status

komust is at v0.1.0-SNAPSHOT and not yet published to Maven Central. It is in active development ahead of a first release.