Archive for the 'Testing' Category

Wed
22
Aug '07
Random acts of testing
by Frank Spychalski filed under Testing, Work

I recently bought Beautiful Code. In chapter 7 Alberto Savoia writes the essay “Beautiful Tests” about the use of randomized tests to easily create a wide range of inputs for a system under test.

I really like and use his idea of randomized tests. But there is one very important hint missing in the chapter:

Initialize the random number generator for every test to a fixed seed!

Why? Tests should be repeatable! Otherwise you can never be sure if you have fixed a bug from the previous test run, because you don’t know if the same test data was created.

Why for every test? Again: tests should be repeatable! If you want to run a single test and the random number generator was initialized for the whole test suite, you behavior will change for all but the very first test case.