Minh Thai
Minh Thai

Reputation: 578

Scalatest GeneratorDrivenPropertyChecks init seed

I'm using Scalatest 3.1.0-SNAP13 and cannot find how to specify the init seed option from this PR. I'm using SBT to run the test so if there is a way to specify this option in build.sbt would be ideal.

Upvotes: 3

Views: 502

Answers (2)

Minh Thai
Minh Thai

Reputation: 578

I managed to get it working with:

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

Result:

[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

Upvotes: 0

Mario Galic
Mario Galic

Reputation: 48420

The -S flag seems to be disabled in 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
}

However it is seems to be enabled in 3.2.x, so try

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

and

testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-S", "1568769615146")

Upvotes: 5

Related Questions