Re: Testing a class which utilizes randomness

Jarod Eells <[email protected]> Fri, 4 Apr 2014 10:55:24 -0700
Newsgroups gmane.comp.programming.test-driven-development
Message-ID <[email protected]>
On Fri, Apr 04, 2014 at 12:23:49PM -0400, Mark Levison wrote:
> Desirable? - by definition - randomness can and should occasionally
> duplicate something. Testing a random number generator is very hard.
> 
> Cheers
> Mark

Testing a RNG doesn't have to be hard.
Just have to roll the dice a sufficient number of times and bin out the results.
Then check that the bins are filled according to the expected statistical distribution.
If you want a higher accuracy for your test then make more bins and/or roll more numbers.

Jarod Eells