Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publishing Code Coverage Results from ReportGenerator not working

Tags:

I am having trouble getting my code coverage reports to work, or rather, to get DevOps to pass my parameters correctly. If I download the build directory (zipped in the build), the ReportGenerator reports are available, but they don't get published. So I know that part is working at least. :)

However, when the publish step runs it creates new reports and uses those instead. My Yaml file is as follows:

## Generate Reports
- task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4
  displayName: Generate Code Coverage Reports
  inputs:
    reports: '**\coverage.cobertura.xml'
    targetdir: 'results'
    reporttypes: 'HTML;HtmlInline_AzurePipelines;Badges;Cobertura'
    assemblyfilters: '-*tests*'
    continueOnError: true


# Publish Code Coverage Reports
- task: PublishCodeCoverageResults@1
  displayName: Publish Code Coverage Results
  inputs:
    disable.coverage.autogenerate: true
    summaryFileLocation: $(Build.SourcesDirectory)\results\cobertura.xml
    reportDirectory: $(Build.SourcesDirectory)\results
    codecoverageTool: cobertura
    continueOnError: true

However, when I run in Debug, I get the following output:

##[debug]disable.coverage.autogenerate=undefined

I have tried the following options for passing this parameter:

disable.coverage.autogenerate: true
disable.coverage.autogenerate: 'true'
disable.coverage.autogenerate: 1

None of them have successfully passed anything to the task.

Without this flag set, the task overwrites the HTML reports generated by ReportGenerator and outputs the following:

##[warning]Ignoring coverage report directory with Html content as we are auto-generating Html content

I am working based upon the information pasted by Daniel Palme (author of ReportGenerator) here, as well as reading the actual code for the task here.

My source code is being open sourced, so if logs or more information help you provide an answer, it is all available here. A build with a good log is here. The Yaml file is here, and is called from the various other repositories in the project.

Any advice on how to get around this issue would be appreciated.

like image 334
Martin Noreke Avatar asked Jul 02 '19 19:07

Martin Noreke


People also ask

How do I get code coverage results?

Code coverage option is available under the Test menu when you run test methods using Test Explorer. The results table shows the percentage of the code executed in each assembly, class, and procedure. The source editor highlights the tested code.

How do I check Azure Devops code coverage?

The code coverage summary can be viewed on the Summary tab on the pipeline run summary. The results can be viewed and downloaded on the Code coverage tab.

How do I publish code coverage report in SonarQube?

You will see how to publish code coverage to SonarQube in 2 simple steps. Enable “xml” parameter in rktracer configuration file to generate SonarQube xml file. Set reports path in sonar properties file to SonarQube xml file in project .

How do I enable Azure Devops code coverage?

As already explained in my previous article, the very first thing to do to add code coverage calculation is to install a NuGet package called Coverlet. This package must be installed in every test project in your Solution. So, running a simple dotnet add package coverlet. msbuild on your test projects is enough!


1 Answers

Well, in standard operating procedure, get annoyed, write a long post on Stack Overflow, find a nugget somewhere, and solve your own problem.

It is not a parameter, but rather an environment variable that needs to be set. Adding the following to the start of the Yaml file takes care of it.

variables:
  disable.coverage.autogenerate: 'true'

Leaving this here to save the next person stuck on this problem days of trouble shooting. :/

like image 142
Martin Noreke Avatar answered Sep 22 '22 12:09

Martin Noreke