question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Coverlet does not generate code coverage

See original GitHub issue

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.

https://stackoverflow.com/questions/54627918/view-code-coverage-report-on-azure-devops-portal/54738732#54738732

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:15

github_iconTop GitHub Comments

3reactions
CodesharpJonascommented, Aug 20, 2019

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!

0reactions
MarcoRossignolicommented, Jul 7, 2020

I tried to use p:DebugType but as this option is not available with coverlet.exe so I am not able to use it.

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 image

If you need further help pls open a new issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found