I have functions that uses math/rand
to "randomly" sample from a Poisson and another from the binomial distribution. It is often used by other functions that also return random values like h(g(f()))
where f()
g()
and h()
are random functions.
I placed a rand.Seed(n)
call in main()
to pick a different seed every time the program is run and it works fine.
My question is for unittests for these PRNG functions and the functions that use them using the builtin testing
package. I would like to remove the randomness so that I can have a predictable value to compare with.
Where is the best place to place my constant value seed to get deterministic output? At the init() of the test file or inside every test function, or somewhere else?