5

I have several tests distributed over several classes.

I would like to run only the first test from the first class:

The class is:

class Step1_PrimarySpec 

The test is:

  test("case1: Primary (in isolation) should properly register itself to the provided Arbiter")

I tried:

sbt test-only Step1_PrimarySpec

and:

sbt test-only Step1_PrimarySpec 1

and:

 sbt test-only "*Step1_PrimarySpec 1"

and:

 sbt test-only "*Step1_PrimarySpec"

However, all of these commands ran the entire test suite.

So how can I run only that specific test?

bsky
  • 19,326
  • 49
  • 155
  • 270

2 Answers2

6

You must place the double quotes around the whole command like this:

sbt "test-only <test-name>"

And according to this answer you should camelCase it to testOnly and use the -z argument

Community
  • 1
  • 1
Ori Popowski
  • 10,432
  • 15
  • 57
  • 79
3
sbt "testOnly *Step1_PrimarySpec -- -z mytest"

That will run the test named mytest from the class (not the file) named Step1_PrimarySpec.

By using the *, the test runner saves us from specifying its fully qualified class name. i.e. org.path.to.Step1_PrimarySpec

donhector
  • 875
  • 1
  • 10
  • 21