【问题标题】:ScalaTest / SBT "testOnly com.acme.someText -- -n Slow" ignores all testsScalaTest / SBT "testOnly com.acme.someText -- -n Slow" 忽略所有测试
【发布时间】: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


    【解决方案1】:

    假设你使用的是org.scalatest.tagobjects.Slow而不是它被实现为object Slow extends Tag("org.scalatest.tags.Slow")所以你需要执行testOnly com.acme.ship.ShipSpec -- -n org.scalatest.tags.Slow或者定义你自己的标签fe:case object Slow extends Tag("Slow")

    【讨论】:

      猜你喜欢
      • 2018-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-27
      • 2023-03-20
      • 1970-01-01
      • 2016-09-14
      • 2014-07-26
      相关资源
      最近更新 更多