-
Notifications
You must be signed in to change notification settings - Fork 392
Description
Now that coverlet supports different coverage types (line, branch, and method), it would be awesome if we could pass in a switch along with the Threshold switch to designate which coverage style dictates the threshold. The switch could accept a comma seperated list of coverage types to check against the threshold. The default value would check all coverage types against the threshold.
I think this would be a great "Up For Grabs" item too as everything is there to make this happen. It's really just allowing the new parameter and passing it to the task which would then respect the parameter.
For example:
Let's say we have a project TestApp and TestApp.Tests. Let's also say that when we run the command: dotnet test /p:CollectCoverage=true .\Tests.Unit\Tests.Unit.csproj that it results in the following coverage %'s:
+---------+--------+--------+--------+
| Module | Line | Branch | Method |
+---------+--------+--------+--------+
| TestApp | 28.6% | 33.3% | 25% |
+---------+--------+--------+--------+
Now let's say we have a new switch that will apply the threshold based on the coverage type. Let's say that the switch is ThresholdType.
If we were to run the command: dotnet test /p:CollectCoverage=true /p:ThresholdType=Line /p:Threshold=30 then the build should FAIL since the line coverage is below 30%.
If we were to run the command: dotnet test /p:CollectCoverage=true /p:ThresholdType=Branch /p:Threshold=30 then the build would PASS since the branch coverage is above 30%
If we were to run the command: dotnet test /p:CollectCoverage=true /p:ThresholdType=Method /p:Threshold=30 then the build would FAIL since the branch coverage is below 30%
If we were to run the command: dotnet test /p:CollectCoverage=true /p:ThresholdType=Line,Branch /p:Threshold=30 then the build would FAIL since the line coverage is below 30%
If we were to run the command: dotnet test /p:CollectCoverage=true /p:ThresholdType=Method,Line /p:Threshold=20 then the build would PASS since the line and method coverage types are above 20%