Skip to content

Configuration

mutato init creates a .mutato/ folder next to your solution holding the config (config.json) and a .gitignore that keeps report output out of your repo — reports land in .mutato/reports/ by default. Config keys mirror the CLI flag names; any CLI flag overrides the matching config value, and relative paths resolve against the folder holding .mutato/.

{
"$schema": "https://mutato.dev/schema/v1/config.json",
"project": "src/Polly.Core/Polly.Core.csproj",
"tests-project": "test/Polly.Core.Tests/Polly.Core.Tests.csproj",
"filter": "Polly.Retry.RetryHelper",
"workers": 4,
"timeout": 10,
"json": ".mutato/reports/report.json",
"html": ".mutato/reports/report.html",
"thresholds": { "high": 80, "break": 60 }
}

filter is a type or namespace prefix to mutate and timeout is the per-mutant timeout in seconds. thresholds colour the score in the run summary, and break also gates the exit code (see Exit codes below; --threshold-break <n> overrides it). thresholds.basis picks the score they compare against: "covered" (the default) leaves out mutants no test reaches, and "all" counts them as survived, as Stryker’s score does. The summary prints both scores either way, and when more than 10% of mutants have no covering test it names the files they are in. Unknown keys print a warning rather than failing the run.

project and tests-project each take a string or an array, and --project and --tests-project can be given more than once (a flag replaces the config’s list). A test project tests every project under mutation that it references, directly or through another project; nothing pairs them by hand. Every project under mutation must be referenced by at least one test project, and every test project must reference at least one of them, or the run stops before building. Each test project is built once, and a project two of them reference compiles once.

Each test project’s suite runs once unmutated first, and all of them must pass before any mutant runs. Then each test project runs the mutants of the projects it references, in the order given, skipping any that an earlier one killed. A mutant counts as killed if any test project killed it, and as survived only if it survived every test project that covers it. The run has one score over every project’s mutants, and thresholds.break gates it. The summary prints a line for each project and each test project under it, and the reports prefix each covering or killing test with its test project’s name.

"project": ["src/Lib/Lib.csproj", "src/Lib.Extras/Lib.Extras.csproj"],
"tests-project": ["test/Lib.Tests/Lib.Tests.csproj", "test/Lib.Integration.Tests/Lib.Integration.Tests.csproj"]

Given projects but no test projects, the run takes every test project that references one of them and is named for one of them (Lib.Tests for Lib) or references one directly; one named for a project the others depend on goes first. It looks for them in the git checkout of the first project listed (the working directory, outside git), and nowhere else: list tests-project yourself when a test project lives outside it. Two test projects that load a project built for different target frameworks are refused, since each loads the framework its own reference picks and --tf can’t change that: make their references agree, or run them apart.

A type, member or local function marked [ExcludeFromCodeCoverage] gets no mutants. Stryker.NET and coverage tools honour the same attribute, so no mutato-specific marker is needed in your source.

For calls rather than declarations, such as your own throw helpers, list them in ignore-methods (C# only; there is no CLI flag for it):

"ignore-methods": ["*Exception.ctor", "MyLib.*.Throw*", "Guard.Against.*"]

The globs are Stryker.NET’s: * matches within one dotted segment, a pattern matches the end of a name (Assert matches Debug.Assert), a constructor is Type.ctor, and case is ignored. A pattern matches the call as written or its resolved Namespace.Type.Method, so MyLib.*.Throw* also reaches an unqualified ThrowWildcard(). No mutant is made anywhere inside a matched call, and the statement that only makes the call isn’t removed either.

// comments and trailing commas are allowed, the same leniency as appsettings.json and launchSettings.json. The $schema line, which mutato init writes for you, points editors at the config’s JSON Schema: you get completion and hover docs for every key, typos are flagged, and VS Code stops marking the comments as errors.

A legacy ./mutation-config.json (the pre-.mutato shape) still loads when no config.json exists, and mutato init migrates it. --config <file> points at any other config file (one named mutation-config.json is read as the legacy shape).

When mutato init finds a Stryker.NET config — stryker-config.json (or .yml / .yaml, in Stryker’s order) in the current directory, else in the test project’s folder — it offers to carry its settings over into the new config.json as real keys. On a terminal it asks first, previewing what would and wouldn’t carry over; without one (piped, CI, --plain) it doesn’t import unless told to, because an imported since narrows every later run to the diff and thresholds.break gates the exit code — not something a script should pick up from a file it never named. Either way init prints a line saying what it found and what it did.

Flag Effect
--from-stryker [path] Import without asking. With no path, the file Stryker itself would read (above); with one, that file.
--no-stryker Leave the Stryker config alone: don’t ask, don’t import.

What maps, and what doesn’t:

Stryker key In mutato
thresholds.high, thresholds.break thresholds.high, thresholds.break, plus thresholds.basis: "all": Stryker’s score counts uncovered mutants as survived, and mutato’s default basis leaves them out.
thresholds.low Not imported: mutato’s thresholds have only high and break.
since (enabled — an object without enabled: false) since = since.target (Stryker’s default: master). Note mutato diffs the working tree against merge-base(<target>, HEAD) and scopes to changed lines; Stryker diffs against the target’s tree and mutates changed files.
since.ignore-changes-in Not imported (no equivalent).
concurrency workers.
configuration configuration.
target-framework tf.
mutate files, where the glob means the same files: a leading **/ is kept as-is, a project-relative path is rooted at the project’s folder, match-everything (**/*) needs no key. ! exclusions, {start..end} spans and a ** mid-path are listed as not imported — and if any include can’t be mapped, none are, since a partial list would mutate less than Stryker did.
test-projects tests-project, the whole list in its order, each path rebased from the Stryker config’s folder. A --tests-project given to init wins.
project Checked against the discovered pair (and used to settle an ambiguous one, as test-projects is); discovery or your flags win a disagreement, and init says so.
solution Not imported: mutato builds the target/test pair.
additional-timeout, timeout-ratio Not imported: Stryker’s slack on top of measured test time isn’t mutato’s per-mutant ceiling (timeout).
ignore-methods ignore-methods, as-is: the glob syntax is the same.
mutation-level, ignore-mutations, reporters, dashboard-*, baseline, … Not imported (no equivalent).

Every key that isn’t imported is listed in init’s output with the reason. YAML configs are detected but not read — copy their settings by hand. An existing .mutato/config.json is never rewritten, so the import only happens on the run that creates it.

mutato doesn’t read // Stryker disable comments, and init doesn’t edit your source. Instead it lists each comment it finds under the target project, with what to do about it:

  • A region that covers whole declarations (disable all … restore all around a method or constructor, or disable once all right above one): add [ExcludeFromCodeCoverage] to them. init writes out the attribute with the Stryker reason as its Justification.
  • Part of a method, disable once on a statement, or only some mutators: there is no tool-neutral equivalent, and init says which case applies. To leave the code out, extract it into a method and mark that.
Flag Purpose
--project <csproj> The project to mutate (code under test).
--tests-project <csproj> The test project to build and run. Repeat it to run several against one project, in that order.
--tests <dll> Use a prebuilt test assembly and skip the build.
--filter <prefix> Restrict mutation to a type or namespace prefix.
--test-class <classes> Run only these test classes. See Choosing the tests.
--exclude-test-class <classes> Never run these test classes.
--configuration <name> / -c MSBuild configuration to build and mutate (default Debug). Match your CI: a suite only green in Release (allocation, GC-lifetime or timing assertions) needs Release, which also keeps #if DEBUG code that never ships out of the score.
--workers <n> Number of warm worker hosts. Default: the machine’s physical cores, at most logical CPUs minus one (Windows: logical CPUs minus one). Setting it also caps cold runs at the same number; by default they are limited by the CPU and memory in use, up to one per logical CPU.
--timeout <seconds> Per-mutant timeout ceiling.
--json <path> Write a Stryker-schema JSON report.
--html <path> Write an HTML report.
--config <file> Read a specific config file.
--threshold-break <n> Exit 2 when the score is below n% (overrides thresholds.break).
--threshold-basis covered|all The score the verdict and the break read (overrides thresholds.basis). covered (default) leaves out mutants no test reaches; all counts them as survived, as Stryker’s score does. The summary prints both scores either way.
--history <path> Where the run history lives (default: in the user’s cache, shared by the clone’s worktrees).
--no-history Neither read nor write the run history.
--no-reuse Re-run every mutant instead of reusing its verdict from the run history.
--no-precompile Don’t precompile the suite before the run.
--no-optimize Compile the code under test without optimizations, as its configuration builds it.

Start with a narrow --filter on a single type; widen it once the baseline is green and the score looks sane.

By default every test in the test project can decide a verdict. To keep slow or flaky tests out (end-to-end tests that spin up the real app, say), exclude their classes:

Terminal window
mutato --exclude-test-class '*EndToEnd*'
mutato --test-class 'MyLib.Tests.*' --exclude-test-class SlowTests,FlakyTests

Both flags take a comma-separated list and can be repeated. A pattern is a class name with * for any run of characters: MyLib.Tests.ParserTests matches that class, a name without a dot (ParserTests, *EndToEnd*) also matches a class’s bare name in any namespace, and a nested class is Outer+Inner or Outer.Inner. Case matters. A class is used if it matches any --test-class pattern (or there are none) and no --exclude-test-class pattern.

For a repo that never wants some tests used for mutation, put it in the config once:

"exclude-test-class": "*EndToEnd*,MyLib.Tests.Integration.*"

The two keys are separate, so a --test-class on the command line still keeps the config’s exclusions.

mutato matches the patterns itself rather than handing them to the test framework’s own filter, so they mean the same thing on every host (xUnit, TUnit, MTP, VSTest). Where a framework has to be told on its command line (the MTP host, or a cold run that starts the test app directly), it gets the exact class names the selection resolved to. The selection covers the coverage pass as well as every warm rerun and cold run: a test left out never covers a mutant and never kills one. A selection that matches no test stops the run before any mutant is scored.

The selection is part of what the run history records about each run, so repeating a run with the same selection reuses its steady verdicts, and a run with another selection, or none, decides them again. The order the patterns are written in doesn’t matter.

Every run ends by merging what it learned about each mutant into its run history: the verdict, the test that killed it, how it was decided, and how steady that has been. The next run uses it two ways.

Known killers run first. Every kill is still observed in the run that reports it; the history only picks which test goes first.

  • Warm runs put last run’s killer at the front of the mutant’s covering tests, so the run stops on it instead of first paying for every faster test.
  • Cold runs (static initializers, code that only runs once per process) try the killer alone in a fresh process with the mutant active, instead of running the whole suite. That’s tried only where a whole-suite run costs many times what starting a worker does, and never on a test that fails alone even without a mutant. On a TUnit suite whose 72 cold kills each ran a 16-second suite, run CPU fell by half.

If last run’s killer no longer fails, the mutant is decided exactly as it would be without a history.

Steady verdicts are reused. A mutant isn’t run again when nothing that decided it has changed: its own source lines, the rest of the method, property or field it sits in (an edit to a comment or to spacing doesn’t count; in F# indentation and line breaks do), the tests that cover it, how it was run (warm or cold), mutato’s version, the test host, the test project, the target framework the tests ran against, the configuration, the test selection, and for a hang the --timeout. A covering test counts as unchanged when its name and its code are: the compiled code of the test method and of everything it reaches in the test projects (helpers, fakes, including one a container or new T() builds from a type argument or a typeof, lambdas, its class’s set-up, its data rows), plus its assembly’s attributes and embedded resources. Editing one test re-runs only the mutants it covers. A test whose display name can’t be tied to one method is checked against all the test code. A mutant that runs outside any test, or in a static initializer, also needs the whole suite’s test names and code unchanged, since any test can reach it.

What isn’t checked: a change to code outside the mutant’s own method, property or field (another method, or a field it reads) that alters what a test sees, files a test reads (snapshots, data files), and package versions. Pass --no-reuse after changing those. Three kinds of verdict qualify:

  • Survivors, the expensive part of a run, since a survivor runs every covering test. One run is enough.
  • Kills, once a named test has killed the mutant two runs in a row (not necessarily the same one: which covering test fails first can change from run to run). A wrong kill would inflate the score, so a kill needs more evidence than a survivor does.
  • Hangs, which each cost a timeout and a fresh worker. A hang is inferred from a time budget, and a busy machine can fake one, so it needs three runs in a row. Two are enough when each ran at least five times as long as its tests take unmutated (a busy machine slows a run by two or three times, not five), or crashed the test process on its own, as a stack overflow does.

A kill that mutato normally reads twice (one hit outside a test, or off its test’s flow) is read once when last run saw the same test kill it. The other way round, a kill of a mutant that survived last run is read a second time in a fresh worker. A test can fail on what an earlier mutant left behind in the same worker, and such a kill doesn’t repeat there, so it isn’t recorded as a flip. And a survivor of a mutant last run saw killed, under the same code and tests, is read again in a fresh worker before it’s reported: a cache an earlier mutant filled in the warm worker can hide what the mutant changes. A kill there counts only if its failing test passes with no mutant active, in that worker or alone in a new one; a test that fails alone either way (it needs another test’s set-up) leaves the mutant to a cold full-suite run, and its verdict is kept as a cold one.

A mutant whose verdict has ever flipped between survived and killed under the same covering tests is never reused: it’s run every time. A verdict that changes along with its covering tests (a new test now kills it) is explained by that change, so it isn’t counted as a flip, and editing the covering tests forgets earlier flips: they were seen under other tests. Each run also re-runs a rotating twentieth of what it could reuse and checks the history against it, so every reused verdict is observed again at least every 20 runs, and a disagreement stops it being reused. A verdict no run has observed for 40 runs is re-checked whatever its turn, for runs that alternate between --filter scopes. Reused verdicts say so in the report’s status reason and on the trust banner. Pass --no-reuse, or set "reuse": false, to re-run them all.

Refresh it now and then. The rotation bounds how many runs a verdict goes unchecked, not how many days, and what reuse can’t see (package versions, files a test reads) drifts with time. When a run reuses verdicts that last ran more than 30 days ago, it says how many and suggests a full run. A scheduled --no-reuse run, weekly say, re-runs everything and writes it all back, so every run after it reuses fresh verdicts. In CI, see below.

The second unmutated pass is remembered too. The default --recheck pass runs the suite twice in one process, to check it can be run twice and to find mutants that only run on first touch. Its answer depends on every test, all the code under test and the packages they load, so the history keeps it against a fingerprint of every file in the tests’ output directory, which holds the packages a test project copies there (a package loaded from elsewhere isn’t in it). A rerun with any change there, even a comment edit, runs the pass again. A run where nothing in it changed takes the answer instead, but only after two clean passes in a row under that exact build, and never once a pass under it has failed. The pass still runs every fifth run, so a test that fails only sometimes on its second run still has a chance to show up, and once it does, that build never skips the pass again. The run says when it took the answer, and so does the trust banner. --recheck always runs the pass, and --no-reuse takes nothing from the history.

Which mutants a pass finds first-touch only can change between runs of a suite that runs its tests in parallel: whichever test fills a cache first decides what the second pass sees. So the history also marks each mutant a pass found, and a run’s first-touch set is its own answer plus every mark that still holds. A mark holds until the mutant’s own method, property or field changes, or any test’s name or code does, or mutato’s version, the test host or the test project, target framework, configuration or test selection.

Replayed across 29 consecutive commits of two real projects, the survivor rule reused 92–94% of survivors and the kill rule over 36,000 kills, and every verdict they would have got wrong was a flaky mutant that flipped back the next commit.

Where it lives. In your user cache, not the repo: ~/.cache/mutato on Linux (or $XDG_CACHE_HOME/mutato), ~/Library/Caches/mutato on macOS, %LOCALAPPDATA%\mutato on Windows. Set MUTATO_CACHE_DIR to move it. There is one file per project per clone, and every worktree of the clone shares it, so a new git worktree starts with what the others learned. It’s protobuf, about 30 bytes a mutant, and it isn’t meant to be committed: it changes every run.

What survives an edit. Mutants are matched by their file, member, operator and source lines, not by line number, so an edit elsewhere in a file keeps its mutants’ history. Tests are matched by display name, so a history from one checkout works in another. A run never replaces the file: worktrees on other branches share it, so a mutant this run didn’t see may still be someone’s. What no run has seen for 90 days is dropped. Two runs finishing together both land.

Set history in the config, or pass --history <path>, to keep it somewhere else. --no-history skips it for one run.

Point MUTATO_CACHE_DIR at a directory your CI caches. On GitHub Actions:

- name: Restore mutato history
uses: actions/cache/restore@v4
with:
path: ${{ runner.temp }}/mutato-cache
key: mutato-history-${{ runner.os }}-${{ github.ref_name }}-${{ github.run_id }}
restore-keys: |
mutato-history-${{ runner.os }}-${{ github.ref_name }}-
mutato-history-${{ runner.os }}-
- name: Mutation test
run: mutato --since origin/main --plain
env:
MUTATO_CACHE_DIR: ${{ runner.temp }}/mutato-cache
- name: Save mutato history
if: always()
uses: actions/cache/save@v4
with:
path: ${{ runner.temp }}/mutato-cache
key: mutato-history-${{ runner.os }}-${{ github.ref_name }}-${{ github.run_id }}

A GitHub cache can’t be overwritten, so each run saves under its own key and the next restores the newest by prefix: this branch’s own history first, else the default branch’s (a pull request can read its base branch’s caches). The save runs on always() so a run that fails --threshold-break still keeps what it learned. Any CI cache works the same way: restore the directory, run with MUTATO_CACHE_DIR pointing at it, save it.

For the periodic refresh, run the same job on a schedule with --no-reuse and no --since. It runs on the default branch and saves under that branch’s key, which pull requests restore from:

on:
schedule:
- cron: "0 3 * * 1" # Mondays, 03:00 UTC
# ... the same restore and save steps as above, with:
- name: Mutation test (full refresh)
run: mutato --no-reuse --plain
env:
MUTATO_CACHE_DIR: ${{ runner.temp }}/mutato-cache

A run starts many test processes: the coverage pass, a worker per lane and a fresh one each time a mutant hangs or crashes it, and a cold run for each mutant that needs a fresh process. Each would JIT-compile the same framework, test and target code. So after the build, mutato compiles the assemblies in the tests’ output folder to native code (ReadyToRun) with crossgen2, once for the whole run. The run prints how many it precompiled and how long that took.

  • Only optimized assemblies. Packages are compiled, and so are your own assemblies when you build Release (-c Release) and the code under test, which mutato compiles optimized by default. A Debug build of anything else (your test project) is left to the JIT: the runtime never recompiles a Debug assembly’s code, so precompiled Debug code would run slower in hot loops than the JIT’s, and left alone it behaves exactly as it always has. The IL stays in each file, and the runtime compiles any method whose native code it can’t use.
  • Images are cached in mutato’s cache, by content, so a run only compiles assemblies it hasn’t seen before or the build changed. An image no run has used for 30 days is deleted. In CI, the cache directory from above keeps them too.
  • It pays off with many fresh processes. Suites whose mutants hang, crash or need cold runs often start many test processes and gain the most (10–30% CPU in our measurements); a suite that runs in a few long-lived lanes gains little. With everything cached, it costs a fraction of a second.
  • crossgen2 comes from NuGet. It isn’t part of the SDK (the SDK downloads it when a project publishes with PublishReadyToRun). mutato uses the one in your NuGet packages folder, or downloads the version matching your .NET runtime through your own NuGet sources the first time. If that fails (offline, a source that doesn’t carry it), the run goes on without precompiling, says why, and tries again a day later.
  • Only in mutato’s own build output. With --tests (a prebuilt test assembly) or --shared-output, the folder is yours, and mutato leaves it alone.

Pass --no-precompile, or set "precompile": false, to turn it off.

mutato compiles the projects it mutates with optimizations (/optimize+), whatever the configuration. Everything else about the build stays as configured: the configuration’s defines (so #if DEBUG code and Debug.Assert still run in a Debug build), and your test projects, which are built as usual.

  • It’s faster. Instrumented Debug code runs several times slower than optimized code. On a survey of 22 open-source libraries, suites with heavy tests ran 10–40% faster with it (Markdig 39%, Cronos 31%), and none got slower beyond noise.
  • It’s closer to your own build in one way. Instrumentation makes Debug stack frames larger. Unoptimized, a test that recurses deeply can overflow the stack under mutato alone, crashing the run’s coverage pass or killing mutants that your own test run would let survive.
  • It can differ from Debug in others. Optimized code ends a local variable’s lifetime at its last use rather than at the end of the method, and compiles async methods to structs that don’t allocate when they complete synchronously. A test that depends on the Debug behaviour, such as an object staying alive until the method returns, goes red. A red Debug baseline suggests --no-optimize for this reason.

Pass --no-optimize, or set "optimize": false, to build the code under test exactly as its configuration says. Each choice keeps its own run history: verdicts decided with optimized code are not reused without it, and the other way round. F# targets are always built as configured.

Survivors are the normal output of mutation testing, not a failure: a completed run exits 0 whatever its score unless you set a break threshold.

Code Meaning
0 The run completed (and the score cleared thresholds.break, if one is set).
1 No trustworthy result: red or empty baseline, build or instrumentation failure, bad flag or config.
2 The score is below thresholds.break / --threshold-break. On the default covered basis a run with no covered mutants is never below break; with thresholds.basis: "all" only an empty run is.
130 Aborted with Ctrl-C; the partial results are still reported.

For TUnit suites mutato runs TUnit’s own engine in-process (--host tunit-runner, the default). It discovers once per worker and runs each mutant’s covering tests as one TUnit session, without the per-run Microsoft Testing Platform pipeline (~85 ms/run), behind the same warm-pool, coverage and timeout machinery. Hooks, constructor and property injection, data sources, conditional skips and parallel constraints all run as TUnit runs them, so verdicts are TUnit’s. If it can’t bind the suite’s TUnit, the run uses the MTP host.

--host tunit-direct drives the source-generated test delegates itself instead of running the engine. On a fast unit suite it can run, it is a few percent faster; for anything it can’t host faithfully (constructor/property injection, lifecycle hooks) it falls back to the MTP host for that run.