How to run a single scala test with scoverage?
Asked Answered
P

1

7

I know that sbt clean coverage test will generate coverage report using all test cases on the project, this takes ages to finish even with the warm JVM.

I wish to run coverage on the tests for the code I wrote so, I tried to run a single testcase like sbt coverage test-only package.ScalaSpec and I get the following error.

ERROR

[scala-project] $ coverage test-only package.ScalaSpec <set>:1: error: eof expected but 'package' found. coverageEnabled in ThisBuild := true test-only package.ScalaSpec ^ [error] Error parsing expression.

Podagra answered 17/6, 2017 at 9:50 Comment(1)
For some reason the sbt coverage "test-only package.ScalaSpec" didn't work for me, it throws the same exception but this works sbt coverage "test:testOnly package.ScalaSpec"Podagra
P
9

Surround your fully-qualified package name in quotes.

coverage is failing because it is parsing the command as though the test goal is the first argument to coverage, and the qualified package name package.ScalaSpec as the second.

What you want to do instead is give coverage only one argument like this:
sbt coverage "testOnly package.ScalaSpec"

Before, coverage is given the command test as its goal, followed by an unexpected 2nd parameter.
After, coverage is given the command testOnly package.ScalaSpec as its goal.

Periderm answered 2/8, 2017 at 20:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.