> Thanks for the explanation. It makes sense that we start with a given
> seed and then each iteration is different because it re-uses the same
> Random instance (or whatever static state?) without re-initialization?
>

It doesn't reuse the same random instance - it's not that simple - it
hierarchically forks the random seed between tests, classes, reiterations
etc., and then initializes the context's random so that runs are
predictable and repeatable even if you run a subset of tests for the given
main seed. Random instances are also not reused between threads in an
attempt to make failures reproducible (this, of course, is not fool-proof).

If you care to look, there are more documented examples with somewhat
increasing complexity here:
https://github.com/randomizedtesting/randomizedtesting/tree/master/examples/maven/src/main/java/com/carrotsearch/examples/randomizedrunner

In particular, these talk about hierarchical seed propagation:

https://github.com/randomizedtesting/randomizedtesting/blob/master/examples/maven/src/main/java/com/carrotsearch/examples/randomizedrunner/Test004MoreRandomness.java
https://github.com/randomizedtesting/randomizedtesting/blob/master/examples/maven/src/main/java/com/carrotsearch/examples/randomizedrunner/Test006RepeatingTests.java

D.

Reply via email to