1

We have an api in .net5, we were using coverlet.msbuild to validate our code coverage but our solution has 50 csprojs and we were hitting a bug where some projects returned 0% of coverage, so we changed the package to coverlet.collector, our problem now is that coverlet.collector does not support threshold validation.

At the end of we have an xml file with cobertura format and we just want to run a command to see if the code coverage reported is OK and let the PR continue its process.

Juan Zamudio
  • 373
  • 11
  • 35

1 Answers1

1

I've also faced that problem. The solution is to use coverlet directly. You can install it as a global tool for dotnet. Note that, I wasn't able to properly gather coverage without flag --no-build. My working command is:

"C:\Program Files\dotnet\dotnet.exe" C:\Users\dalec\.nuget\packages\coverlet.console\3.1.2\tools\net5.0\any\coverlet.console.dll \
C:\Users\dalec\source\repos\ZTR.AI\ZTR.AI.Common\ZTR.AI.Common.Core.Tests\bin\Debug\net5.0\ZTR.AI.Common.Core.Tests.dll \
--target "C:\Program Files\dotnet\dotnet.exe" \
--targetargs "test C:\Users\dalec\source\repos\ZTR.AI\ZTR.AI.Common\ZTR.AI.Common.Core.Tests\ZTR.AI.Common.Core.Tests.csproj \
--configuration Debug --no-build" --output C:\Users\dalec\source\repos\ZTR.AI\testrestults\ZTR.AI.Common.Core.Tests/ \
--format cobertura --format json --threshold 69

Unfortunately, I still cannot gather coverage on Ubuntu.

Mikołaj
  • 89
  • 10