danielpalme / ReportGenerator

ReportGenerator converts coverage reports generated by coverlet, OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.
https://reportgenerator.io
Apache License 2.0
2.58k stars 281 forks source link

Reportgenerator generated html and xml file is mismatched with its input Cobertura xml file #614

Closed waseemkhan1989 closed 1 year ago

waseemkhan1989 commented 1 year ago

Describe the bug I am using squish coco as code coverage tool to generate report in .csmes format (it is a squish coco format). To generate a Cobertura xml format report, I am using following instruction provided by squish coco:

/opt/coco-5.0.3/bin/cmreport --coverage-mcdc --csmes=./coverage_report.csmes --cobertura=Coverage.xml --cobertura-azure-devops --cobertura-source=.

It generates Coverage.xml report. After that, I use ReportGenerator as task on my Azure pipeline to convert Coverage.xml into html file:

- task: reportgenerator@5 displayName: ReportGenerator inputs: reports: $Path/to/build-Directory/coverage/Coverage.xml targetdir: $Path/to/build-Directory/coverage/Cobertura-html-report reporttypes: 'HtmlInline_AzurePipelines;Cobertura;Badges' assemblyfilters: '-xunit*'

It generates the Cobertura.xml file and html files including index.html file. As I want to publish the coverage report on Azure dashboard, I use the following task:

The problem is, the Cobertura.xml report generated by ReportGenerator has different values for line and branch coverage from the original Coverage.xml report which is input to Report Generator. The Cobertura.xml and its corresponding generated html file has same values.

Why Cobertura.xml has different values for branch and coverage? Should it not only convert the Cobertura Coverage.xml file into html without changing any statistics?

P:S: I extensively search this problem but could not find a satisfactory answer.

danielpalme commented 1 year ago

@waseemkhan1989 If you already have a Cobertura file, there is no need to let ReportGenerator produce the file again. You should be able to pass the original Cobertura file to PublishCodeCoverageResults.

As ReportGenerator supports a lot of coverage format, the Cobertura output format may differ from the original input file. If you like, you can send me your Cobertura file and I will see if I can improve the one generated by ReportGenerator. You can share the file privately via email: reportgenerator@palmmedia.de

waseemkhan1989 commented 1 year ago

@danielpalme Plz check the email.

danielpalme commented 1 year ago

I will have a look within the next days.

danielpalme commented 1 year ago

I just answered your email. For me the metrics calculated by Squish are not correct. See my email for a concrete example.