Reproducing a ScalaCheck test run

scalacheck

Solution

As of today, this is possible (see scalacheck#263). There are some nice examples here: Simple example of using seeds with ScalaCheck for deterministic property-based testing.

In short, you can do:

propertyWithSeed("your property", Some("seed")) =
  forAll { ??? }

and the seed will be printed when this property fails.

Problem

This was asked as a "bonus question" in https://stackoverflow.com/questions/12639454/make-scalacheck-tests-deterministic, but not answered: Is there a way to print out the random seed used by ScalaCheck, so that you can reproduce a specific test run? There is a hacky way: wrap a random generator to print its seed on initialization and pass it to `Test.Parameters`. Is there a better option?

Original source

Related problems