1

When using the cobertura-maven-plugin for Java, I get a nice <instrumentation> block in the config where I can put the incredibly useful <ignoreMethodAnnotation> block.

Best thing to happen to coverage since the gin martini.

Now I'm using scoverage-sbt, but I can't seem to find where I can configure it! The available keys in build.scala are limited. I can do package exclusion and file exclusion but there's nowhere to tell cobertura anything else.

Is there a -D I can supply on the SBT command line, maybe?

2 Answers2

0

There is no similar configuration in Scoverage ATM.

update:

You can use special comments to exclude a block of code from instrumentation:

// $COVERAGE-OFF
...
// $COVERAGE-ON$
  • I'm aware of this - the problem is that this is across all test profiles, whereas with the annotation, one can mark the block as active in one test profile and not in another. Thus, I could have `@ExcludeFromUnitTesting` and `@ExcludeFromIntegrationTesting` and they would behave appropriately. With the $COVERAGE_OFF$ one cannot differentiate. – Christopher Ambler Dec 16 '16 at 18:17
0

One way to pass parameters and commands into SBT from the command line is:

$ sbt 'set coverageEnabled := true' clean coverage test coverageReport coverageAggregate codacyCoverage

Where you call SBT once and then separate each parameter or command by a space.

In this example, I first set the property coverageEnabled := true and then run several commands in sequence: clean, coverage, test, coveraReport, coverageAggregate and finally codacyCoverage

Please note that setting properties like this requires that you enclose your statements in single quotes, for example:

$ sbt 'set coverageEnabled := true'...
vromancas
  • 183
  • 2
  • 11