scoverage / sbt-scoverage

sbt plugin for scoverage
Apache License 2.0
648 stars 157 forks source link

how to switch between statement or branch coverage as default #221

Open rajeshpg opened 7 years ago

rajeshpg commented 7 years ago

I would like to use branch coverage as the default coverage strategy. So is there a way to switch the coverage strategy.

gslowikowski commented 7 years ago

What do you mean by switching coverage strategy?

rajeshpg commented 7 years ago

I guess scoverage considers statement coverage percentage as default to check against minimum coverage. I would like to use branch coverage percentage instead.

gslowikowski commented 7 years ago

I was thinking about new setting, something like that:

  lazy val coverageBranchMinimum = settingKey[Double]("minimum branch coverage")

This would be independent of coverageMinimum setting, with zero as default value for backward compatibility. To switch the strategy (as you named it), you would have to set coverageMinimum value to zero, and coverageBranchMinimum to value greater than zero. WDYT?

Anyway, I'm blocked with development by this issue. Waiting for the project owner to react. I want this problem to be fixed first.

rajeshpg commented 7 years ago

that'a a great idea. i will try to implement and do PR if you are ok with.

ches commented 6 years ago

I'd like to have this as well.

Alternatively there could be a new setting like coverageMinimumCheck := Branch with a default of Statement for backward compatibility, so there are not two different keys for setting the threshold (unless some people actually want to check/enforce both, then maybe it's beneficial to have two).

To switch the strategy (as you named it), you would have to set coverageMinimum value to zero, and coverageBranchMinimum to value greater than zero. WDYT?

coverageMinimum already defaults to 0 so you wouldn't need any extra boilerplate to only enable coverageBranchMinimum, so that approach sounds good to me too. 👍

kitbellew commented 6 years ago

We have a need for a fine-grained control for coverage minima (similar to various levels supported by JaCoCo for java http://www.jacoco.org/jacoco/trunk/doc/check-mojo.html#rules).

Here's a proposed solution: https://github.com/scoverage/sbt-scoverage/pull/253

Bongani commented 5 years ago

I'd also like to have branch coverage. Is there any update on this ticket?

alexmsmartins commented 5 years ago

The branch coverage is already part of?PR #253 . Thanks for that @kitbellew

Is there anything stopping it from getting merged?

It would really be great to be able to use it in the next release.