TIL: run specific tests with
Run specific test suites by passing them as arguments to
> sbt testOnly com.blah.StackSpec com.blah.ATSomeSpec
testOnly task also accepts wildcards, which is how I usually specify the
> sbt testOnly **.StackSpec **.AT*Spec
Sometimes a test suite is big and/or slow, and you really want to run a single
test or a subset of related tests. The following will run all tests which
contain “for cars” in their names (
-- is required to mark the start of
parameters passed verbatim to the test runner):
> sbt testOnly **.StackSpec -- -z "for cars"
Executing the full
sbt command over and over again on every test run is rather
slow. Instead, launch the sbt command prompt (also know as interactive mode)
and run the tasks from there. It will incur the startup overhead only once.
> sbt [info] Loading project definition from /my/blah/project [info] Set current project to blah (in build file:/my/blah/) [blah] $ testOnly **.StackSpec -- -z "for cars" # [... runs tests ...] [blah] $ testOnly **.StackSpec -- -z "for cars" # [... runs tests again, without startup overhead ...]