How to get new random values at every run of a testset?


How can I have functions like randstring() generate new values at every run of a testset.
For example, in the following test, I have to restart a julia session to get a different value from the previous execution.

using Test
using Random

@testset "Test random" begin

From the @testset docs:

Before the execution of the body of a @testset, there is an implicit call to Random.seed!(seed) where seed is the current seed of the global RNG. Moreover, after the
execution of the body, the state of the global RNG is restored to what it was before the @testset. This is meant to ease reproducibility in case of failure, and to allow
seamless re-arrangements of @testsets regardless of their side-effect on the global RNG state.

So the solution is to add a Random.seed!() call before the @testset.