dotnet test --collect:"XPlat Code Coverage" /p:CoverletOutputFormat=cobertura
Running dotnet test --collect "Code Coverage"
at the solution level now automatically merges code coverage for all your test projects. See here for more information.
# dotnet test --collect "Code Coverage;Format=cobertura"
dotnet test -s .runsettings
💡 This doesn't work:
dotnet-coverage collect -f cobertura -o report.cobertura.xml "dotnet test -s .runsettings"
.
-
Install Coverage Gutters if not already installed.
-
Make sure the setting
coverage-gutters.coverageFileNames
insettings.json
includes"coverage.cobertura.xml"
as shown below:"coverage-gutters.coverageFileNames": [ "lcov.info", "cov.xml", "coverage.xml", "jacoco.xml", "coverage.cobertura.xml" ]
-
From Command Palette, select Coverage Gutters: Display Coverage after you have run unit tests (see previous section).
When building for CI/CD, we want to keep package versions locked based on lock file(s). If you encounter NU1403
, try doing the following (source):
dotnet nuget locals all --clear
git clean -xfd
git rm **/packages.lock.json -f
dotnet restore