HOW TO GET A CODE COVERAGE REPORT IN C# PROJECT

The following instructions are based on this two tutorials:

What will you need?

Steps

Run these commands while located on the Test Project directory:

  1. Getting a covertura file: dotnet test --collect:"XPlat Code Coverage" (if that doesn't work, try alternative: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura)
  2. Generating a report from the covertura file: reportgenerator "-reports:Path\\To\\TestProject\\TestResults\\{guid}\\coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:Html