16

If you have 2 tests defined in your SBT project:

class Spec1 extends Specification {
  def is =
    "Tests for specification 1" ^
      p ^
      "Test case 1" ! todo ^
      end
}

and

class Spec2 extends Specification {
  def is =
    "Tests for specification 2" ^
      p ^
      "Test case 2" ! todo ^
      end
}

Then running test from inside SBT will execute both these tests. What is the simplest way to run only one of these tests?

Jack
  • 15,582
  • 17
  • 86
  • 162

1 Answers1

19

Use the test-only sbt command.

sbt> test-only com.example.MySpec

You can even use a wildcard to run a range of tests. See How to execute tests that match a regular expression only?

Community
  • 1
  • 1
Régis Jean-Gilles
  • 31,374
  • 4
  • 75
  • 92
  • 9
    If you don't want to enter the `sbt` shell first, the executable expects only a single argument, so you'll have to pass the whole command in quotes. Here, `sbt "test-only com.example.MySpec"` or `sbt "test-only *MySpec"` – broadmonkey Oct 19 '15 at 15:55