coverlet-coverage / coverlet

Cross platform code coverage for .NET
MIT License
2.93k stars 385 forks source link

[Feature Request] Calculating total coverage for whole solution #1569

Open tlorenz9 opened 6 months ago

tlorenz9 commented 6 months ago

I have a solution with multiple projects and test projects which are contributing to the total coverage of the solution. Coverlet seems to check the coverage thresholds for every single test project, even when used with the MergeWith option.

My request would be to add an option to only check the last total coverage, because this will be the relevant one for the whole solution.

dotnet test --configuration Release /p:CollectCoverage=true /p:CoverletOutputFormat=\"json,opencover\" /p:ThresholdStat=total /p:Threshold=80 /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json" /p:Exclude=\"someExclusions\" -m:1

So if we could have a "whole total" option for thresholdStat, this would be great. Or am I missing something?

Bertk commented 5 months ago

Hi, we use reportgenerator which merges coverage files and also allows to filter classes, assemblies and source files. This tool also allows to define thresholds as well e.g. --minimumCoverageThresholds:lineCoverage=${{parameters.minimumLineCoverage}}

see also coverlet CI:

ReportGenerator minimumCoverageThresholds settings

Note (dotnet test)

NET 7.0.200 SDK and later

If you specify the --output option when running this command on a solution, the CLI will emit a warning (an error in 7.0.200) due to the unclear semantics of the output path. The --output option is disallowed because all outputs of all built projects would be copied into the specified directory, which isn't compatible with multi-targeted projects, as well as projects that have different versions of direct and transitive dependencies. For more information, see Solution-level --output option no longer valid for build-related commands.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 3 months with no activity.