coverlet: Coverlet does not generate code coverage
Main 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?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 15
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!