coverlet-coverage / coverlet

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

Coverlet ThresholdType mulitple Value Note Working #1143

Closed huangydyn closed 3 years ago

huangydyn commented 3 years ago

Enviroment

daveMueller commented 3 years ago

Seems like a bug. Thanks for reporting, I'll take a look.

daveMueller commented 3 years ago

The feature for multiple thresholds isn't available in version 3.0.3 yet. It will be in the next release (https://github.com/coverlet-coverage/coverlet/pull/1123#issuecomment-811898370).

Up to that point you can consume the nightly (https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/ConsumeNightlyBuild.md).

Also you have to take into a account that you can't pass property values containing a semicolon or comma to msbuild. One way to work around this is to escape the quotes (https://github.com/dotnet/msbuild/issues/471), e.g.

dotnet test /p:CollectCoverage=true /p:Threshold=\"10,10,8\" /p:ThresholdType=\"line,branch,method\"

I will update the documentation for this.

MarcoRossignoli commented 3 years ago

closed in https://github.com/coverlet-coverage/coverlet/issues/1143

Ogglas commented 2 years ago

The feature for multiple thresholds isn't available in version 3.0.3 yet. It will be in the next release (#1123 (comment)).

Up to that point you can consume the nightly (https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/ConsumeNightlyBuild.md).

Also you have to take into a account that you can't pass property values containing a semicolon or comma to msbuild. One way to work around this is to escape the quotes (dotnet/msbuild#471), e.g.

dotnet test /p:CollectCoverage=true /p:Threshold=\"10,10,8\" /p:ThresholdType=\"line,branch,method\"

I will update the documentation for this.

This failed for me using Powershell.

MSBUILD : error MSB1006: Property is not valid. Switch: 92

What worked for me though was using MSBuild escaping. Comma is %2c

Complete example:

dotnet test C:\Users\oscar\source\repos\project\Repository.sln --configuration Release /p:CollectCoverage=true /p:Include="[*]Repository.Web.Controllers.*" /p:Threshold="100%2c90%2c80" /p:ThresholdType="method%2cline%2cbranch"

https://github.com/dotnet/msbuild/issues/2999#issuecomment-366101535