bsky
bsky

Reputation: 20222

sbt test-only specific test

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?

Upvotes: 6

Views: 12066

Answers (2)

donhector
donhector

Reputation: 915

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

Upvotes: 3

Ori Popowski
Ori Popowski

Reputation: 10662

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

Upvotes: 6

Related Questions