Dotnet Unit test with Coverlet- How to get coverage for entire solution and not just a project

If you are using the coverage.collector nuget, it will generate separate test result file for each project.

You can then use reportgenerator tool to merge multiple results into one.

Here is how we are doing it in our CI:

dotnet test <solution-file> --collect:"XPlat Code Coverage"
dotnet tool install --global dotnet-reportgenerator-globaltool --version <version-number>
reportgenerator -reports:<base-directory>/**/coverage.cobertura.xml -targetdir:<output-directory>/CoverageReport -reporttypes:Cobertura

This will generate a combined report for all your test projects.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)