.NET code coverage with coverlet and ReportGenerator, and mutation testing with Stryker.NET

xUnit Testing & CI/CD in .NET November 13, 2026 bash

Coverage tells you which code was executed, not that it was verified.

bash
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# ======================================================================
# Q: Code coverage: what target do you set? How do you know your tests are good?
#
# - Coverage tells you which code was executed, not that it was verified. A test
#   with no assert still produces coverage.
# - A sensible target: high coverage in the domain / application layers, not
#   100% everywhere. In CI: a threshold for new code, so coverage doesn't drop.
# - Mutation testing (Stryker): it changes the code (e.g. > to >=) and checks
#   whether some test fails. If none does, the tests don't verify that rule.
# ======================================================================

dotnet test --collect:"XPlat Code Coverage"          # coverlet → coverage.cobertura.xml
reportgenerator -reports:**/coverage.cobertura.xml -targetdir:coverage-report
dotnet stryker                                         # mutation testing (Stryker.NET)