【发布时间】:2017-09-11 13:42:32
【问题描述】:
我正在使用带有自定义生成器的 Scalatest/Scalacheck。我观察到即使某些测试失败,测试也会被标记为成功。在下面的示例测试中,“应该添加处理时间戳”是伪造的。然而 sbt 测试通过了。
+ OK, passed 100 tests.
[info] - should add product info to event
[info] - should not alter rest of event
+ OK, passed 100 tests.
! Falsified after 0 passed tests.
> ARG_0: List("([B@27d10fe1,...)")
> ARG_0_ORIGINAL: List("([B@3c8057ce,...)")
[info] - should add processing timestamp
[info] ScalaTest
[info] Run completed in 4 seconds, 792 milliseconds.
[info] Total number of tests run: 3
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 3, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[info] Passed: Total 3, Failed 0, Errors 0, Passed 3
[success] Total time: 8 s, completed Sep 11, 2017 6:54:28 PM
为什么测试没有失败??
更新: sbt 0.13,scalatest 3.0.1,scalacheck 1.13.4,测试用例是
it should "add processing timestamp" in {
Prop.forAll(sizedGen(TestInputGen.Generate)) { in =>
val out = processor.input(in)
out.forall(o => {
val outTS = o._2.get("timestamps")
(outTS.getModule() == "PrimaryProcessor")
})
}
}.check
【问题讨论】:
-
测试失败。任务成功。
-
"""[info] 测试:成功 3,失败 0,取消 0,忽略 0,待处理 0""" --- 失败测试为 0。
-
好的。你能提供失败但通过的测试吗?您用来运行的命令(我假设是 sbt 测试)以及 sbt 和 scalatest 的版本。
-
我已经用您询问的信息更新了帖子。是的,我运行 sbt test 或 testOnly。
标签: scala scalatest scalacheck