I need to skip specifications and individual tests while running my test suite. Here's an example such test:
package models
import org.specs2.mutable._
import org.specs2.runner._
class SlowTaggedSpecification extends Specification{
"SLOW_SPEC" should {
"BAD!! Not Skipped" in {
"axbcd" must find( "bc".r )
}
} section( "SLOW_SPEC" )
}
class SlowFastTaggedSpecification extends Specification{
"SLOW_FAST_SPEC" should {
"run fast test" in {
"axbcd" must find( "bc".r )
} section( "FAST_TEST" )
"SLOW_TEST should be skipped (BAD!! NOT Skipped)" in {
"axbcd" must find( "bc".r )
} section( "SLOW_TEST" )
} section( "SLOW_FAST_SPEC" )
}
I need to skip SLOW_SPEC
(entire spec) and SLOW_TEST
(indvidual test only).
My build.sbt is:
scalaVersion := "2.11.1"
libraryDependencies += "org.specs2" %% "specs2" % "2.3.12" % "test"
When I run the following command line:
sbt '~testOnly models.* -- -l SLOW_SPEC'
sbt '~testOnly models.* -- -l SLOW_TEST'
none of the tests gets skipped. May I know how do I exclude a specification and an individual test using tags? Also, what would be the sbt syntax if I weren't using testOnly
, but test
?
sbt '~test -- -l SLOW_SPEC'
causes sbt to complain. My sbt version is 0.13.5
Any pointers would be appreciated.
The command line argument to exclude tags is
sbt> ~testOnly models.* -- exclude SLOW_SPEC
If you want to exclude tags when using the test
command you need to use Test.Arguments
in your build.sbt
file:
testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "exclude", "SLOW_SPEC")
If you want to specifically run a SLOW_SPEC test, then use the following:
sbt 'set testOptions in Test := Seq()' '~testOnly models.SlowTaggedSpecification'