
gomutants
The best mutation testing tool for the Go development loop.
Find the gap. Fix the test. Verify the mutant. Repeat in seconds.
Coverage tells you a line ran. gomutants tells you whether a test would catch it breaking, then gives you the controls to close that gap while you are still developing: changed-code scope, exact covering-test routing, stable single-mutant reruns, source overlays, and a checkpointed content-addressed cache.
gomutants earns that position through the complete path from a code change to a verified test fix. The advantage is the workflow, not any one checkbox: other tools have more mutators or win particular cold benchmarks, but they do not combine the same development-loop controls in one tool. See the comparison.
The Go development loop
# 1. Find test gaps introduced by this branch.
gomutants --changed-since main -o mutants.json ./...
# 2. Add or strengthen the test for a surviving mutant.
# 3. Verify that exact mutant instead of rerunning the package.
gomutants --run-mutant-id \
'internal/cli/cli.go:parseArgs:CONDITIONALS_BOUNDARY#2' \
--threshold-efficacy 100 ./...
# 4. Rerun the changed scope. Unaffected verdicts come from the cache.
gomutants --changed-since main ./...
The targeted command bypasses the old cached verdict, runs the tests that cover that mutant, and writes the fresh result back to the cache. Exit 0 means the test killed it; exit 10 means it still lived; exit 1 means the rerun produced no verdict at all (NOT COVERED, NOT VIABLE, TIMED OUT, EQUIVALENT, or INFRA ERROR), so treat only 0 as a confirmed kill. Mutations are applied with go test -overlay, so the source tree is never rewritten.
Why gomutants leads this loop
- Work on the change, not the repository.
--changed-since <ref> uses the merge base and includes uncommitted edits to tracked files, keeping local and pull-request runs focused on the code being developed. A brand-new file is invisible to git diff until it is staged, so git add it before trusting the count.
- Run only the relevant tests. Per-test coverage routing maps each mutant to the tests that cover its line;
--integration extends that routing across importing packages when the real assertion lives downstream.
- Verify one fix directly. Stable mutant IDs and unique prefixes turn “did this test kill it?” into one targeted run rather than another full mutation pass.
- Keep completed work. The default content-addressed cache reuses a verdict only while the mutated file, the rest of its package, and the tests that could exercise it all remain byte-identical. Mid-run checkpoints also let interrupted runs resume instead of starting over.
- Make the workflow repeatable. An auto-loaded
.gomutants.yml keeps operators, exclusions, thresholds, routing, timeouts, and cache behavior with the project; CLI flags can override it for one run.
- Keep the working tree clean. Byte-level overlays preserve Go syntax, including generics, without copying or editing source files.
- Get an actionable result. Terminal diffs, JSON, Stryker, self-contained HTML, GitHub annotations, and the Claude Code plugin put each survivor where a developer or coding agent can act on it.
Measured feedback time
On the published Apple M1 Pro benchmark, unchanged out-of-the-box reruns complete 120–150× faster on the larger targets because cached mutants do not execute again:
| Target | Cold OOB run | Warm rerun | Speedup |
|---|
| spf13/cobra | 410 s | 2.7 s | ~150× |
| prometheus/model/labels | 342 s | 2.8 s | ~120× |
| prometheus tsdb-4 | 2768 s (~46 min) | 19 s | ~145× |