ajr
ajr

Reputation: 974

Why dotnet test tool is not creating code coverage report?

My project structure is the following:

.
├── Application
├── Application.Core
├── Application.Domain
├── Application.Tests
├── Application.IntegrationTests
└── README.md

And the command to run my test I use the following input:

dotnet test $folder.FullName -c Release --no-build /p:CoverletOutput='$root\coverage' /p:MergeWith='$root\coverage.json' /p:CoverletOutputFormat=opencover 

where $folder is pointing to my Application.Tests path: C:\projects\coredemoapp\CoreDemoApp.Tests and $root to C:\projects\coredemoapp\

All the tests are run successfully. However, the problem is that coverage.json nor coverage.opencover.xml files are not created.

I also tried to use coverlet directly with the following command:

coverlet <path to test.dll> -
-target "dotnet" --targetargs "test --no-build" --merge-with $root\coverage.json --format opencover

, everything works on my local machine with explicit path to the dll. But in the case of running the command with the previous $folder.FullName as the <path to assembly>, coverlet assumes a path to the debug dll, not release version as it should and fails.

Link to the full build script

Upvotes: 13

Views: 20517

Answers (1)

ajr
ajr

Reputation: 974

Basically I forgot to add the coverlet msbuild NuGet package into my test project. After that, all worked fine with the following command:

dotnet test $folder.FullName -c Release --no-build /p:CollectCoverage=true /p:CoverletOutput=$root\coverage /p:CoverletOutputFormat=opencover

Upvotes: 34

Related Questions