2

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

Pradeep
  • 1,108
  • 1
  • 15
  • 31
  • Hi @Prado, How about the issue? Does the answer below resolved your question? If not, would you please let me know the latest information about this issue? – Vito Liu Oct 07 '20 at 09:15
  • This issue is still open. What I understand from the responses below is that if we use "Visual Studio Test" task in the build then that somehow prevents uploading HTML reports later in the pipeline. This is not confirmed yet. I am waiting for someone to provide more concrete response. I am not looking for "Coverlet" option here. – Pradeep Oct 07 '20 at 10:12
  • Could you try the [answer](https://stackoverflow.com/a/54738732/13903626) and then kindly share the result here? – Vito Liu Oct 08 '20 at 10:04

3 Answers3

1

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

Vito Liu
  • 7,525
  • 1
  • 8
  • 17
1

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

Ε Г И І И О
  • 11,199
  • 1
  • 48
  • 63
0

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

enter image description here

enter image description here

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107