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.56k stars 279 forks source link

minimumCoverageThresholds:lineCoverage not working #653

Closed markusroessler closed 6 months ago

markusroessler commented 6 months ago

Describe the bug When executing reportgenerator with --minimumCoverageThresholds:lineCoverage=100on a cobertura report with line-rate="0.1433", the exit code is 0 a no error is reported. --minimumCoverageThresholds:branchCoverage=100 and --minimumCoverageThresholds:methodCoverage=100 do report the coverage errors as expected Settings-Description

To Reproduce

Reportgenerator Version 5.2.1.0

danielpalme commented 6 months ago

Will have a look within the next days.

danielpalme commented 6 months ago

I can't reproduce your problem.

What line coverage does your HTML report contain? I referring to this card in the report: image

Does this indicate a coverage of 100%?

The line-rate attribute in the Cobertura file is not relevant to evaluate if the coverage is below 100%. ReportGenerator calculates its own line/branch/method coverage metrics. Those are relevant for the evaluation and are also visible in the HTML report.

If you like, you can also send me your Cobertura file via email: reportgenerator@palmmedia.de

markusroessler commented 6 months ago

here is an example cobertura file generated from a .NET project: coverage.cobertura.xml.txt The html report shows a line coverage of 50% - but reportgenerator completes with exit code 0.

danielpalme commented 6 months ago

I still can't reproduce the problem. I' m using this version: https://www.nuget.org/packages/dotnet-reportgenerator-globaltool/5.2.1

Executed command: reportgenerator -reports:coverage.cobertura.xml -targetdir:output -reporttypes:Html --minimumCoverageThresholds:lineCoverage=100

Output:

PS C:\temp> reportgenerator -reports:coverage.cobertura.xml -targetdir:output -reporttypes:Html --minimumCoverageThresholds:lineCoverage=100
2024-02-23T20:43:29: Arguments
2024-02-23T20:43:29:  -reports:coverage.cobertura.xml
2024-02-23T20:43:29:  -targetdir:output
2024-02-23T20:43:29:  -reporttypes:Html
2024-02-23T20:43:29:  --minimumCoverageThresholds:lineCoverage=100
2024-02-23T20:43:29: File '\Users\mroessler\Workspaces\Samples\ReportgeneratorLineCoverageSample\Sample\Class1.cs' does not exist (any more).
2024-02-23T20:43:29: Writing report file 'output\index.html'
2024-02-23T20:43:29: The line coverage of 50% is below the minimum threshold of 100%.

image

markusroessler commented 6 months ago

I just realised it actually works on Windows but not Mac OS (Version 5.2.1 on both platforms). Sorry for leaving out this information - I didn't expected this to be relevant.

danielpalme commented 6 months ago

Very strange behavior. But --minimumCoverageThresholds:branchCoverage=100 and --minimumCoverageThresholds:methodCoverage=100 do work on Mac OS?

markusroessler commented 6 months ago

yes, they both work on Mac OS (and Linux) - very strange indeed.

markusroessler commented 6 months ago

Is it a language thing maybe? My Mac's system language is english currently - Windows is german

danielpalme commented 6 months ago

Is it a language thing maybe? My Mac's system language is english currently - Windows is german

I don't think so. And the there is no difference in the implementation between lineCoverage, branchCoverage and methodCoverage

Will try to debug on Linux (I don't have a Mac available).

markusroessler commented 6 months ago

might have something to do with commandline parsing. This does NOT work on Mac: reportgenerator -reports:coverage.cobertura.xml -targetdir:output -reporttypes:Html --minimumCoverageThresholds:lineCoverage=100

This does work :) reportgenerator -reports:coverage.cobertura.xml -targetdir:output -reporttypes:Html XXXXX --minimumCoverageThresholds:lineCoverage=100

Same happens for minimumCoverageThresholds:methodCoverage and branchCoverage - so not lineCoverage related. It just looks like the first "--"-argument is ignored.

danielpalme commented 6 months ago

Please try again with version 5.2.2. This new release should fix the issue.

markusroessler commented 6 months ago

I can confirm the issue is fixed in 5.2.2 on Mac OS. Thank you for the fast support!