2

我正在使用Scalatest 3.1.0-SNAP13并且找不到如何从此PR指定 init 种子选项。我正在使用 SBT 运行测试,因此如果有办法指定此选项build.sbt将是理想的。

4

2 回答 2

4

-S标志似乎在 3.1.x中被禁用:

parseLongArgument(seedArgs, "-S") match {
  case Some(seed) => // Randomizer.defaultSeed.getAndSet(Some(seed))
    println("Note: -S for setting the Randomizer seed is not yet supported.")
  case None => // do nothing
}

但是它似乎在 3.2.x中启用,所以尝试

libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.0-M1" % Test

testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-S", "1568769615146")
于 2019-10-10T13:02:14.520 回答
0

我设法让它工作:

// specify an initial seed 0
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-S", "0")

结果:

[info] SummaryTest:
[info] - hello *** FAILED *** (49 milliseconds)
[info]   GeneratorDrivenPropertyCheckFailedException was thrown during property evaluation. (SummaryTest.scala:8)
[info]     Falsified after 0 successful property evaluations.
[info]     Message: 0 was not greater than 1
[info]     Location: (SummaryTest.scala:10)
[info]     Occurred when passed generated values (
[info]       ""
[info]     )
[info]     Init Seed: 0
于 2019-10-11T04:04:14.627 回答