Exclude specific tagged tests from SBT when using ScalaTest

I have many disappointments trying to run all my tests from sbt - with the exception of a specific tag. Here is what I am trying to run:

 testOnly * -- -l "com.my.project.path.tags.ValidationTest" 

I tried many variations of this command, including replacing * with a class path or package path as follows:

 testOnly "com.my.project.path.somePackage" -- -l "com.my.project.path.tags.ValidationTest" 

And I tried using without quotes around the package.

I just read that testOnly used in the new version of sbt , not test-only . I tried this syntax (and many variations) and nothing works. My tests are configured as follows:

 "some method" should "fail when doing something" taggedAs ValidationTest in { ... } 

I have an object ValidationTest extends Tag("com.my.project.path.tags.ValidationTest") defined in TestTag.scala .

I also tried to do this when the method is defined using the it keyword instead of "some method" should "fail..."

Sbt with ScalaTest shows the following in the section "Include and Exclude Tagged Tests"

 > test-only org.acme.* -- -n CheckinTests > test-only org.acme.* -- -n FunctionalTests -l org.scalatest.tags.Slow > test-only org.acme.* -- -n "CheckinTests FunctionalTests" -l "org.scalatest.tags.Slow org.scalatest.tags.Network" 
+6
source share
1 answer

Just a few guesses:

  • all this syntax only works from the sbt console and does NOT work from the command line;
  • the package name must be WITHOUT quotation marks and must end with an asterisk, the tag must be WITH quotes (for example, testOnly com.my.project.* -- -l "com.my.project.path.tags.ValidationTest" )
  • testOnly applies only to unit tests, if you must have integration tests, you should use, for example. it:testOnly * -- -l "path.to.Tag" .
0
source

All Articles