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.63k stars 283 forks source link

Miss-match between testrunner's coverage console output & generated HTML report #321

Closed stoyandimov closed 4 years ago

stoyandimov commented 4 years ago

I'm running report generator against a opencover report.

The console output:

+------------------------------+--------+--------+--------+
| Module                       | Line   | Branch | Method |
+------------------------------+--------+--------+--------+
| Unic.Services.AudioConverter | 59.25% | 64.7%  | 51.45% |
+------------------------------+--------+--------+--------+

+---------+--------+--------+--------+
|         | Line   | Branch | Method |
+---------+--------+--------+--------+
| Total   | 59.25% | 64.7%  | 51.45% |
+---------+--------+--------+--------+
| Average | 59.25% | 64.7%  | 51.45% |
+---------+--------+--------+--------+

Expected behavior

ReportGenerator HTML report showing Unic.Services.AudioConverter:

Actual behavior

ReportGenerator HTML report shows Unic.Services.AudioConverter:

Screenshots

Here is the script that runs the tests and generates the reports: image

Here is the console output. image

Here is the generated report. image

Please, let me know if you need further information.

danielpalme commented 4 years ago

ReportGenerator counts branches in the following way:

For each line: Get number of branches from XML For each file file: Sum of all lines For each class: Sum of all files For each assembly: Sum of all classes Total: Sum of all assemblies

Only "real" branches ( in OpenCover XML) are taken into account. OpenCover counts differently here, it counts one extra branch per method.

See also: https://github.com/danielpalme/ReportGenerator/issues/236 https://github.com/danielpalme/ReportGenerator/issues/191

stoyandimov commented 4 years ago

Thanks for the explanation.