Suite • opensavvy.prepared.suite.random • Random • setSeed
setSeed
Initializes the underlying Random implementation with seed.
Example:
val int by randomInt()
test("This is a test") {
setSeed(123456789L)
// Even if prepared values are declared outside the test,
// as long as they are accessed after the seed is set,
// they respect the configured seed.
println("Generated number: ${int()}")
}
This function is meant to easily allow reproducing a test failure that only arrives in rare cases by simply adding it at the start of the test with the seed of the failed execution.
This function can only be called before the first random value is generated for the current test, otherwise it throws IllegalStateException.