Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a single scala test with scoverage?

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.

like image 256
Nkokhelox Avatar asked Jun 17 '17 09:06

Nkokhelox


1 Answers

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 "test-only package.ScalaSpec"

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

like image 100
Val H Avatar answered Sep 27 '22 22:09

Val H