I have a test that is non-functional, so I do not want it to affect the coverage report. Other than putting it in a separate project, is there a way to exclude it from the report when running
sbt clean coverage test coverageReport
As it stands, it is obscuring missing coverage by other tests.
To explain better I've made a sample project in GitHub. There are two test classes - MainSpec and DoubleSpec. I've commented out the test in DoubleSpec to show that the test in MainSpec gives 100% coverage. However, it's obscuring that DoubleSpec is "broken". MainSpec is not testing the functionality, only checking the return type.
The example is contrived. I have a much more complex example which I cannot share.
I've tried using coverageExcludedFiles
but this only excludes source from coverage, not tests.
Consider creating a ScalaTest tag
based on which to exclude particular tests only when running coverage
so now executing using
testOnly
like sowill exclude
"double" should "return an Int"
from the coverage report. Note you can still execute all tests withsbt test
.Given above, then to still run tests tagged with
ExcludeFromCoverage
but not include them in coverage consider defining a custom command like so