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.
And here is the output from the code coverage report.
Here is a screenshot of the Azure DevOps log file for the task showing that it executed correctly without any errors.
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?
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