I have a test case that should use a random integer, so I have:
test "test with random integer" do IO.inspect :random.uniform(10) assert true end
This always prints 4 when I run it, although I can see different samples in the output to the console:
Randomized with seed 197796 ... Randomized with seed 124069
I know that I should use :random.seed/1 or :random.seed/3 . I want to use the same seed that will be printed at the end of the test output. That way, if my test fails, I can play it using
mix test --seed 124069
I cannot do this if I use :random.seed(:erlang.now) , for example.
How can I get the seed that ExUnit uses to randomize its test cases inside a test case?
source share