1

Is there a way I could setup a test coverage criteria while running scoverage? Right now I execute the usual following command:

sbt test coverage 

This way I get the result but would like to hard code a criteria; for example statement coverage of 50 percent or branch coverage of 70 percent.

o-0
  • 1,713
  • 14
  • 29

1 Answers1

2

You can set statement coverage threshold on your build setting. If there will be less coverage compare to threshold coverage, it will break the build.

You can set the coverage threshold by adding in your settings of build.sbt

coverageMinimum := 90,
coverageFailOnMinimum := true,

As @mukesh has mentioned in a comment, we can also specify threshold for all multi-projects in the same build by adding above statements.

Mahesh Chand
  • 3,158
  • 19
  • 37
  • 1
    One thing to add: For multi-module project, you can place `coverageMinimum` in individual project's `build.sbt` to give seperate minimum criteria. – mukesh210 Jan 27 '19 at 07:07
  • Yes, it can be done also. Let me update the answer. Thanks for pointing out. – Mahesh Chand Jan 28 '19 at 04:26