Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reproducing a ScalaCheck test run

Tags:

scalacheck

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?

like image 287
Alexey Romanov Avatar asked Feb 02 '14 07:02

Alexey Romanov


2 Answers

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.

like image 197
Minh Thai Avatar answered Sep 22 '22 23:09

Minh Thai


There is no way to do this today. However, it will be implemented in the future, see https://github.com/rickynils/scalacheck/issues/67

like image 35
rickynils Avatar answered Sep 20 '22 23:09

rickynils