codevineyard / sbt-coverage-example

Researching whether coverage can be excluded on some tests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SBT Coverage Example

Running

sbt clean coverage test coverageReport

passes with 100% coverage even though DoubleSpec is commented out.

The problem

How can the project be changed so that MainSpec does not affect coverage, while DoubleSpec does?

Solution 1

Use a combination of test tags and a multi-part sbt script. Each time sbt starts, coverage is off. Run

./runtests.sh

Solution 2

Instead of the run script, add a new command testWithSmartCoverage to build.sbt. Run

sbt testWithSmartCoverage

Solution 3

A more complex terminal command with coverageOff in the middle:

sbt clean coverage "testOnly * -- -l ExcludeFromCoverage" coverageOff "testOnly * -- -n ExcludeFromCoverage" coverageReport

Kudos to Mario Galic for amazing help on Stackoverflow!

About

Researching whether coverage can be excluded on some tests

License:MIT License


Languages

Language:Scala 92.9%Language:Shell 7.1%