This project demonstrates how to generate code coverage reports using .NET with xUnit and Coverlet.
- .NET SDK 8.0 or higher
- Git (optional, for cloning)
Clone this repository or download the source code to your local machine.
From the root directory, run:
dotnet build
To run tests without coverage:
dotnet test
Navigate to the test project directory:
cd Numbers.Tests
Then run tests with coverage:
For Windows Command Prompt / PowerShell:
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
For Git Bash / Linux / macOS:
dotnet test -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura
This generates coverage.cobertura.xml
in the Numbers.Tests directory.
From the test project directory:
dotnet test --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura
This generates coverage file in TestResults/{guid}/coverage.cobertura.xml
- MSBuild Method:
Numbers.Tests/coverage.cobertura.xml
- Collector Method:
Numbers.Tests/TestResults/{guid}/coverage.cobertura.xml