“Beyond Coverage: Test Quality for the Agentic Loop” - Part 4 of 7. The concrete commands and flags for putting Parts 0–3 into practice on a Go + .NET stack, plus the one operational rule that makes mutation testing tractable on a large legacy codebase: scope it to the diff.
For .NET: coverlet for coverage (the negative filter), Stryker.NET for mutation score
(the oracle diagnostic), FsCheck/CsCheck for properties. For Go: built-in
go test -cover + go-carpet, gremlins (or go-mutesting/ooze) for mutation,
gopter/rapid for properties. The non-negotiable trick on a legacy codebase is to run
mutation diff-scoped and incrementally, never repo-wide.
⚠️ Source note: the Stryker.NET flag/threshold details below are drawn from the official Stryker documentation. Those specific claims were queued for adversarial verification but errored out (session limit) in the underlying research run, so treat them as “per official docs, confirm against your installed version.” The conceptual guidance is solid; pin exact flag spellings to your Stryker.NET version.
.NET stack
Coverage - Coverlet
dotnet test --collect:"XPlat Code Coverage" # coverlet.collector
# or for line/branch numbers + thresholds:
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura \
/p:Threshold=0 /p:ThresholdType=line
Use Coverlet output only to find changed lines with zero coverage. Feed those to
ReportGenerator for a diff view. Do not set a high /p:Threshold as a quality gate - that’s the
Goodhart trap from Part 0.
Mutation - Stryker.NET
dotnet tool install -g dotnet-stryker
dotnet stryker # full run (slow - avoid on legacy repos)
dotnet stryker --since:main # ONLY mutate files changed since main ← legacy-friendly
dotnet stryker --with-baseline:main # incremental: reuse prior results, re-test only affected mutants
dotnet stryker --break-at 80 # FAIL the build if mutation score < 80 (hard gate)
Key facts (per official docs):
- Default thresholds are
high: 80,low: 60,break: 0- scores < 60 are flagged “danger,” ≥ 80 “good.” That’s a reasonable industry baseline for “good enough” on a .NET module. --since:<branch>restricts mutation to files changed since a git committish - runs proportional to the diff, not the repo. This is what makes Stryker tractable on a large legacy system.--with-baselinepersists previous results and only re-tests mutants affected by changed source or changed tests - incremental runs that reuse prior work. Ideal for a per-PR agentic gate.--break-at <score>turns mutation score into a CI quality gate.
Properties - FsCheck / CsCheck
// CsCheck - invariant: a commission payment never exceeds the amount owed
Gen.Decimal[0m, 1_000_000m].Sample(owed => {
var paid = CommissionCalculator.Pay(owed);
Assert.True(paid <= owed);
});
Properties are the highest-value oracle for money math - they assert what must always be true and explore inputs you’d never enumerate.
Go stack
Coverage - built-in
go test ./... -coverprofile=cover.out
go tool cover -func=cover.out # per-function %
go tool cover -html=cover.out # visual
go-carpet # terminal heatmap of uncovered lines
Mutation - gremlins (recommended), go-mutesting, ooze
go install github.com/go-gremlins/gremlins/cmd/gremlins@latest
gremlins unleash ./... # full run
gremlins unleash --diff main ./... # diff-scoped (legacy-friendly)
gremlins unleash --dry-run # list mutants without running tests (estimate cost)
gremlins reports two distinct numbers - keep them separate (Part 2):
- Test Efficacy =
KILLED / (KILLED + LIVED)→ oracle strength. - Mutant Coverage =
(KILLED + LIVED) / (KILLED + LIVED + NOT_COVERED)→ reachability.
Alternatives: go-mutesting (older, broad operator set), ooze (library-style, embed in your own tooling). All share the diff-scoping principle.
Properties - gopter / rapid / testing/quick
// rapid - invariant: rounding to cents never loses or invents money
rapid.Check(t, func(t *rapid.T) {
owed := rapid.Float64Range(0, 1e6).Draw(t, "owed")
paid := commission.Pay(owed)
require.LessOrEqual(t, paid, owed)
})
The canonical reference: PIT (Java)
When you read about mutation testing maturity, the gold standard is PIT / Pitest (Java).
Stryker (.NET/JS/Scala) and gremlins (Go) are the spiritual ports. PIT pioneered the practical
moves worth copying: bytecode mutation for speed, incremental analysis, and coverage-guided
mutant selection (only mutate covered lines). If you want to understand why a feature
exists in Stryker/gremlins, the PIT docs usually explain it first.
Running mutation testing on a legacy codebase without it taking all day
This is the make-or-break operational concern. The rules:
- Diff-scope everything. Mutate only files/lines changed in the PR (
--since/--diff). Google’s industrial practice mutates diff-based and skips “arid” lines (uncovered/ uninteresting), which “drastically reduces the number of mutants.” [google] - Mutate only covered lines. A mutant on an uncovered line is guaranteed to survive and tells you nothing new (you already know it’s uncovered). Coverage becomes the input filter to mutation - this is the one genuinely good use of coverage.
- Set a time budget. Cap wall-clock per run (e.g. 10 min). If the diff is huge, sample mutants. Log what you skipped - never let a silent cap masquerade as “all green.”
- Use baselines/incremental mode. Persist results; only re-test mutants affected by the
change (
--with-baseline). - Triage equivalents once, suppress forever. Maintain an ignore-list of known-equivalent mutants so they don’t re-nag every run.
- Start with the crown jewels. Don’t boil the ocean. Turn on diff-mutation for the highest-risk modules first - for a payments system, that means: money calculation, batch-run orchestration, idempotency/reference uniqueness, due-date rules. Expand outward.
With the tools in hand, the next part turns to the hardest audience for all of this: tests an AI wrote. Coverage and even a naive mutation run can both be gamed by a model that’s optimizing for the wrong signal - Part 5 is the grading gauntlet that catches it.
Sources
- [stryker] Stryker.NET configuration & pipeline docs. https://stryker-mutator.io/docs/stryker-net/configuration/ · https://stryker-mutator.io/docs/stryker-net/stryker-in-pipeline/ - flag/threshold specifics per docs; not independently re-verified in this run.
- [gremlins] go-gremlins. https://github.com/go-gremlins/gremlins · https://gremlins.dev/
- [google] State of Mutation Testing at Google. https://research.google/pubs/state-of-mutation-testing-at-google/ - arid-lines/diff approach confirmed (2-1).
- PIT/Pitest reference: https://pitest.org/
← Previous: Part 3 - What the Empirical Research Actually Says · Next: Part 5 - Grading AI-Generated Tests →
The series - Beyond Coverage: Test Quality for the Agentic Loop: 0 · Why Coverage Lies · 1 · The Metric Catalog · 2 · Mutation Testing, Properly Explained · 3 · What the Empirical Research Actually Says · 4 · Tooling for Go and .NET (you are here) · 5 · Grading AI-Generated Tests · 6 · The Readiness Rubric