Search code examples
scalasbtscalatest

scala sbt test-only parameters are only picked up when run from sbt shell


I've tagged a few of my slower running tests with a "SlowTest" tag. When I run my test suite from the sbt shell via the following command:

test-only * -- -l com.company.tags.SlowTest

the 'SlowTest' tests aren't run. However, when I attempt the same from the bash shell via:

sbt test-only * -- -l com.company.tags.SlowTest

all the tests are run, including the slow ones I'm trying to filter out. What am I missing here?


Solution

  • sbt treats each commandline argument as a separate target to run. You simply need to quote each individual command you wish to run, which means all of the arguments you've provided:

    sbt "test-only * -- -l com.company.tags.SlowTest"