【发布时间】:2018-07-05 21:00:38
【问题描述】:
我正在尝试使用 ScalaTest 的标记功能来限制在测试套件中运行的测试范围。不幸的是,它根本不起作用。我尝试过的任何语法都会导致根本没有测试运行。
import org.scalatest.tagobjects._
"Ship service" should {
"return to port" taggedAs(Slow) in {
whenReady(client.getShip(shipId).invoke()) { ship =>
whenReady(client.dock(ship.id).invoke()) { response =>
response should be(Done)
}
}
}
}
我也尝试过使用"return to port" taggedAs(org.scalatest.tagobjects.Slow),但没有任何区别。
当我尝试在 SBT 中仅运行 Slow 测试时,没有运行测试:
sbt:ship-service> testOnly "com.acme.ship.ShipSpec -- -n org.scalatest.tagobjects.Slow"
[info] ScalaTest
[info] Run completed in 13 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
我也试过了:
sbt:ship-service> testOnly "com.acme.ship.ShipSpec -- -n Slow"
sbt:ship-service> testOnly com.acme.ship.ShipSpec -- -n Slow
第一个没有区别。在第二个(不带引号)上,每个测试都会运行,无论应用的标签是什么(所以所有测试,包括未加标签和加标签)。
【问题讨论】:
标签: scalatest