jeudi 2 juillet 2015

How to test properties of random generator

Using Scala, I've a method that return a set of 5 random numbers, that should be between 1 and a constant LIMIT.

What's the best approach to test that a answer will never return more/less than 5 elements, and all elements are between 1 and LIMIT? Making a simple test is easy. But should I make a loop of, lets say, 1000 iterations to better test it? Or there is some feature in unit testing for such cases?

Using Scala and ScalaTest.FunSuite




Aucun commentaire:

Enregistrer un commentaire