Coverlet does not generate code coverage
See original GitHub issueMain Error
After running tests coverlet generates empty cobertura xml file on my build agent
Agent
Azure Devops - Hosted Agent
Issue Description
I’m following a SO post to generate a cobertura code coverage report on a .Net Full Framework 4.7.1.
I’m using coverlet to run ‘dotnet vstest’ and then generate a coverage.cobertura.xml file. This is working on my local machine but when running on the build agent the coverage xml file is just empty of results.
My yaml build step
- powershell: |
"install tools:"
&dotnet tool install coverlet.console --tool-path . --version 1.5.3
"`nrun tests:"
$unitTestFile = gci -Recurse | ?{ $_.FullName -like "*bin\*test.dll" }
Write-Host "`$unitTestFile value: $unitTestFile"
$coverlet = "$pwd\coverlet.exe"
"calling $coverlet for $($unitTestFile.FullName)"
&$coverlet $unitTestFile.FullName --target "dotnet" --targetargs "vstest $($unitTestFile.FullName) --logger:trx" --format "cobertura"
Log output:
calling C:\__w\9\s\coverlet.exe for C:\__w\9\s\Source\Server.Net\ActivityCalendarSvc\ActivityCalendar.Test\bin\Release\ActivityCalendar.Test.dll
Microsoft (R) Test Execution Command Line Tool Version 16.2.0-preview-20190606-02
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
! TestRecurringEntryTestData [895ms]
! TestDetailsMissing [5ms]
! TestSplitEvents [4ms]
Results File: C:\__w\9\s\TestResults\ContainerAdministrator_E1968FE75CB5_2019-08-19_10_52_23.trx
Test Run Successful.
Total tests: 19
Passed: 16
Skipped: 3
Total time: 2.4672 Seconds
Calculating coverage result...
Generating report 'C:\__w\9\s\coverage.cobertura.xml'
| +--------+--------+--------+--------+ |
| Module \| Line \| Branch \| Method |
| +--------+--------+--------+--------+ |
| +---------+--------+--------+--------+ |
| \| Line \| Branch \| Method |
| +---------+--------+--------+--------+ |
| Total \| 100% \| 100% \| 100% |
| +---------+--------+--------+--------+ |
| Average \| ∞% \| ∞% \| ∞% |
| +---------+--------+--------+--------+
Since it does run the tests correctly, and I’ve viewed the trx file, what could be causing it to not outputting any code coverage data?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:15
Top Results From Across the Web
Why dotnet test tool is not creating code coverage report?
Basically I forgot to add the coverlet msbuild NuGet package into my test project. After that, all worked fine with the following command:...
Read more >Coverlet does not generate single coverage report file for ...
We are trying to generate and report Code Coverage to azure server using Coverlet and ReportGenerator. We are collecting coverage report in ...
Read more >Use code coverage for unit testing - .NET
This article discusses the usage of code coverage for unit testing with Coverlet and report generation using ReportGenerator. While this article ...
Read more >Generate Code Coverage Report For .NET Core & .NET ...
Generate console code coverage report with coverlet console ... as coverlet.collector or coverlet.msbuild to the codebase (test projects) => No source code ...
Read more >Code coverage in .NET Core with Coverlet
NET Core CLI and when enabled, will automatically generate coverage results after tests are run. To enable code coverage, you need to run...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I reverted some of my earlier changes to find exactly what or what combinations of parameters to msbuild that did the trick. It turned out it was “/p:DebugType=pdbonly” that was the solution. “/p:DebugSymbols=false” doesnt seem to have made any difference, it works with it set to false.
Once again, thanks for your help!
This option is not related to coverlet .net tool but it’s a setting of project build. It’s a msbuild parameter https://docs.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-properties?view=vs-2019
If you need further help pls open a new issue.