Jonathan's Blog

Random Test Harness

Introduction

Jonathan Fries

Jonathan Fries

I work for Techtonic as the leader of the software delivery group. I am a Certified Scrum Product Owner.


Random Test Harness

Posted by Jonathan Fries on .
Featured

Random Test Harness

Posted by Jonathan Fries on .

I created a basic random testing harness and put the code on GitHub:

https://github.com/jonathan-fries/random_testing

It is very, very basic as the ReadMe file points out. I will most likely do some additional work on it.

As it stands there is no obvious problem with either source of randomness or pseudo-randomness tested.

Both Math.random() and Random.org work fine. That is, when you ask for a bunch of random numbers in a range, they return a result that looks pretty darn random.

This does not explain behavior that I have seen from Math.random().

The next two things that I plan to do are:

  1. Introduce a static, non-variable delay (already in progress).
  2. Develop a basic UI for displaying the results.
  3. Add Crypto.getRandomValues() as another source of randomness

My reasoning for number 1 is that it is clear (so far) with this test harness that using it in a basic way, their is no pattern.

So the experiment would seem to dispel my hypothesis.

It is possible that I was simply seeing patterns where there are no patterns. The human brain is good at that.

But I really did see the same number (selected out of about 1200) come up 3 to 4 times within a set of 20 numbers. And this happened a lot.

So, perhaps it has to do with the way I was calling it. And if I was creating a pattern through manual testing, perhaps a standard delay could reproduce a similar situation. So, I will introduce a delay and see if that produces different results.

If nothing else, I can simply lay to rest my (perhaps human-induced) pattern recognition and sleep easier knowing that pseudo-random is really pretty random after all.

I don't really expect to see any pattern with Random.org. They were just a control and I had recently written code to integrate with them, so I included them for comparison.

Jonathan Fries

Jonathan Fries

I work for Techtonic as the leader of the software delivery group. I am a Certified Scrum Product Owner.

View Comments...