尝试从
sbt
运行我的所有测试,同时排除特定标签,我感到很沮丧。这是我要运行的:
testOnly * -- -l "com.my.project.path.tags.ValidationTest"
我已经尝试了这个命令的许多变体,包括将
*
替换为类的路径或包的路径,如下所示:
testOnly "com.my.project.path.somePackage" -- -l "com.my.project.path.tags.ValidationTest"
我试过在包裹周围加引号和不加引号。
我刚刚读到
testOnly
用于新版本的sbt
而不是test-only
。我已经尝试过这种语法(以及许多变体),但似乎没有任何效果。
我的测试设置如下:
"some method" should "fail when doing something" taggedAs ValidationTest in { ... }
我在
object ValidationTest extends Tag("com.my.project.path.tags.ValidationTest")
中定义了TestTag.scala
。
当使用
it
关键字而不是 "some method" should "fail..."
定义方法时,我也尝试过这样做
Sbt with ScalaTest 在“Include and Exclude Tests with Tags”下显示以下内容
> 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"
只是一些猜测:
testOnly com.my.project.* -- -l "com.my.project.path.tags.ValidationTest"
)it:testOnly * -- -l "path.to.Tag"
。 要运行除具有特定标签的测试之外的所有测试:
sbt "testOnly -- -l com.my.project.path.tags.ValidationTest"
然后做相反的事情,只用标签测试:
sbt "testOnly -- -n com.my.project.path.tags.ValidationTest"