No code coverage generated from ReportGenerator in Azure DevOps

3.4k Views Asked by At

I am using the ReportGenerator task in my Azure DevOps build to generate a code coverage report. The problem is that the generated report is empty.

In my VsTest task that runs the unit tests I have checked the option Code coverage enabled. The .coverage file is correctly generated and the unit tests are all successfully run. However, the generated code coverage report shows that no code was covered by any of the unit tests.

Here is a screenshot of my code coverage Report Generator task.

enter image description here

And here is the output from the code coverage report.

enter image description here

Here is a screenshot of the Azure DevOps log file for the task showing that it executed correctly without any errors. enter image description here

Interestingly the log does show the following

Analyzing 0 classes

Is this because ReportGenerator cannnot find the assemblies / classes? I've tried specififying a value for Source directories but this has made no difference.

Why is the code coverage report showing no code coverage?

1

There are 1 best solutions below

1
On BEST ANSWER

ReportGenerator can not handle .coverage files. You can find the supported formats here: https://github.com/danielpalme/ReportGenerator#supported-input-and-output-file-formats

You can use a tool like OpenCover or coverlet to generate a coverage report in a format that ReportGenerator is able to parse. Or you can convert the .coverage file format. Here you find instructions how this can be done: https://github.com/danielpalme/ReportGenerator/wiki/Visual-Studio-Coverage-Tools