C# Coverlet results always empty

Viewed 2325

have .net core 3.1 Microsoft.net.sdk projects, with lots of async xUnit tests.

  • tried - adding coverlet.msbuild 2.9.0 to the project, and then running: dotnet test Common\Common.csproj /p:CollectCoverage=true / got 100% displayed, but an empty coverage file created
  • tried - adding coverlet.collector 1.3.0 to the project and then running: dotnet test Common\Common.csproj --collect:"XPlat Code Coverage" got a file created in testresults\{guid}\coverage.cobertura.xml - but it just says lines-covered=0

whereas stdout is saying 88 tests run in 4s. What am I doing wrong?

1 Answers

For me coverlet.msbuild works perfect with command: dotnet test Common\Common.csproj /p:CollectCoverage=true /p:IncludeTestAssembly=true /p:CoverletOutputFormat=cobertura /p:ExcludeByFile=\"**/Microsoft.NET.Test.Sdk.Program.cs\"

So, I guess you missed CoverletOutputFormat here.

Related