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

Wrong number for branchcoverage after reportgenerator for cobertura.xml #597

Closed mklpanasiuk closed 1 year ago

mklpanasiuk commented 1 year ago

Describe the bug Wrong number for branchcoverage after reportgenerator for cobertura.xml

To Reproduce

  1. Run: reportgenerator "-reports:coverage.cobertura.xml" "-targetdir:./" "-reporttypes:JsonSummary;Html;Badges"
  2. Open Summary.json or Index.html and check branch coverage, compare with results in coverage.cobertura.xml image

NOTE: the original file coverage.cobertura.xml has been sent to your email adress

danielpalme commented 1 year ago

I will have a look as soon as possible.

danielpalme commented 1 year ago

I guess your cobertura file was generated with coverlet?

I don't know how coverlet calculates the attributes branches-covered="43" and branches-valid="56". But they are not consistent with the other elements in this file.

If you sum up all the <line /> elements with the following attribute: condition-coverage="X% (Y/Z)" you will get the following values: Number of covered branches: 42 Total number of branches: 52

ReportGenerator calculates the same numbers 42/52 (Cobertura: 43/56).

ReportGenerator does not evaluate the attributes branches-covered and branches-valid, it tracks all the branches in the coverage file and calculates it's own sums.

mklpanasiuk commented 1 year ago

Thank you for the reply!