Pradeep
Pradeep

Reputation: 1252

Not able to render Code Coverage HTML results in the "Code Coverage" tab in Azure DevOps

I have a classic build pipeline in Azure DevOps that builds and run tests for a .Net Core 3.1 app. I am using self-hosted build agents running Windows Server 2019 OS

Below is the pipeline screenshot enter image description here

My tasks:

  1. Restore Nuget
  2. Build the solution in release mode
  3. Install latest vstest.console.exe tool
  4. Run tests using above tool and generate .coverage file
  5. Install CodeCoverage.exe from Nuget
  6. PowerShell script to convert .coverage to .xml
  7. Using ReportGenerator task to generate HTML and Cobertura (HTMLInline;HTMLChart;Cobertura)
  8. Publish the code coverage results to the server using Cobertura.xml from step 7 and also uploading HTML report folder

Publish Code Coverage Task enter image description here The HTML report directory is generated by ReportGenerator task.

Build runs successfully Publish Code Coverage task log enter image description here

Build run summary

enter image description here

Published files by the build

enter image description here

Code Coverage tab

enter image description here

Issue: The code coverage tab does not display the HTML reports

Upvotes: 3

Views: 6509

Answers (3)

Ε Г И І И О
Ε Г И І И О

Reputation: 12321

Your issue lies with step 4.

4. Run tests using above tool and generate .coverage file

If a .coverage file is created and left alone, Azure DevOps will pick it up and use it over anything else you create later. So basically your coverage.xml or any generated HTML report is ignored at the Code Coverage tab.

So instead of using VSTest task and whatever you used beneath that, try adding a .Net Core Test to your pipeline and configure it to spit out "XPlat Code Coverage" using coverlet collector. Make sure NOT TO pass in any .runsettings file via --settings. Before doing any of that, you will need to add the NuGet coverlet.collector for all your test projects.

enter image description here

Then add your task to publish the coverage results. You don't need the report generator, it's now built-in.

enter image description here

That's all. Hopefully, you will be able to see the generated HTML getting rendered under Code Coverage tab.

enter image description here

Upvotes: 1

Vito Liu
Vito Liu

Reputation: 8278

This is a known issue on Azure devops. Now, we could only download the report, and open it with Visual Studio.

Azure devops only support the download link for .coverage files currently. The white page you see is a UI glitch. This scenario is only supposed to render a download link to the coverage file.

Besides, this issue has been submitted in this earlier suggestion ticket linked here: support vstest .coverage "code coverage" build results tab

This feature request is On Roadmap, I believe it will be released soon, you can follow this thread to know its latest feedback.

In addition, I found a similar case and I have tested via the answer, set the code coverage tool to Cobertura, then I get the code coverage report in the Azure DevOps pipeline.

enter image description here

Upvotes: 1

Krzysztof Madej
Krzysztof Madej

Reputation: 40533

I don't see you settings so I will share mine which works

enter image description here

enter image description here

Upvotes: 0

Related Questions