sbt testOnly runs multiple tests

Viewed 899

When I run:

sbt testOnly com.blablabla.A

I'm getting the following output:

[error] Failed: Total 19, Failed 6, Errors 0, Passed 13, Ignored 6
[error] Failed tests:
[error]         com.blablabla.A
[error]         com.blablabla.B
[error]         com.blablabla.C
[error] (test:testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 13 s, completed Jul 1, 2020 12:35:08 PM

Why?

I only want to test A.

2 Answers

The reason

sbt testOnly com.blablabla.A

does not work is because here sbt runs in batch mode which means it considers each space-separated value as a separate command and tries to execute them in sequence. For example, it considers testOnly as one command, and then com.blablabla.A as the next command

sbt    testOnly      com.blablabla.A
          |                  |
      1st command      2nd command

The solution is to enclose commands that take arguments themselves in quotes

sbt    clean        compile     "testOnly       TestA TestB"
         |            |             |                |
    1st command   2nd command    3rd command    args to 3rd command

Try

sbt "testOnly com.blablabla.A"
Related