mutannot 0.7.0
See the version list below for details.
dotnet tool install --global mutannot --version 0.7.0
dotnet new tool-manifest
dotnet tool install --local mutannot --version 0.7.0
#tool dotnet:?package=mutannot&version=0.7.0
nuke :add-package mutannot --version 0.7.0
mutannot
This will let you write the mutations that should cause a test to fail directly into your test code.
It can help you make sure that a test actually tests what you think that it is testing, and that the test isn't just turning green for some other reason (for example because it goes down a different branch entirely that just happens to lead to the expected result, or because the assertions are too weak to discover anything).
Currently, only .NET is supported.
Installation
mutannot is a .NET tool and requires the .NET 10 SDK.
Install it globally:
dotnet tool install --global mutannot
Or add it to your repository's tool manifest:
dotnet tool install mutannot
Usage
You add the Mutannot.Annotations NuGet package to your test project (or add a copy of the attribute manually if you prefer to not have a dependency), and then you annotate tests with git patches which, when applied, should cause the test to fail:
open Xunit
open Mutannot.Annotations
[<Fact>]
[<ShouldCatch("""
--- a/Example/Validator.fs
+++ b/Example/Validator.fs
@@ -3,4 +3,4 @@ namespace Example
open System
module Validator =
- let isAllowed (now: DateTime) (date: DateTime) = now.Date <= date
+ let isAllowed (now: DateTime) (date: DateTime) = now <= date
""")>]
member _.``You're allowed to pick the current day``() =
let now = DateTime(2026, 5, 12, 17, 17, 13)
let date = DateTime(2026, 5, 12)
Assert.True (Validator.isAllowed now date)
To run your mutations, you use dotnet tool run mutannot -- run [path/to/testproject.csproj|fsproj]. It will do a control run of the original test cases, and then it will run the same tests again with the patches applied, to confirm that they now fail. Doing so takes a while, so if you just want to quickly check if your git patches are (still) technically valid without running the mutation, use dotnet tool run mutannot -- validate [path/to/directory|path/to/testfile.cs|path/to/testfile.fs].
Use dotnet tool run mutannot -- --help to list all commands and options.
Examples
A simple C# example is available here, and a simple F# example is available here.
Mutannot is also heavily dogfooded, however, so you can find a lot more examples in the program's own integration tests.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.