Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threshold | Add Switch To Apply Threshold Based On Coverage Type #92

Closed
StephenMP opened this issue May 11, 2018 · 1 comment
Closed

Comments

@StephenMP
Copy link
Contributor

StephenMP commented May 11, 2018

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%

StephenMP added a commit to StephenMP/coverlet that referenced this issue May 11, 2018
…s a comma separated string of coverage types to apply to the threshold. It defaults to all coverage types and will ignore any unsupported coverage type
tonerdo added a commit that referenced this issue May 12, 2018
Issue #92 : Added a ThresholdType switch
@tonerdo
Copy link
Collaborator

tonerdo commented May 13, 2018

Fixed in #93

@tonerdo tonerdo closed this as completed May 13, 2018
NorekZ pushed a commit to NorekZ/coverlet that referenced this issue Nov 8, 2018
…s a comma separated string of coverage types to apply to the threshold. It defaults to all coverage types and will ignore any unsupported coverage type
NorekZ pushed a commit to NorekZ/coverlet that referenced this issue Nov 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants