What are best practices for testing programs with stochastic behavior?
Posted
by
John Doucette
on Programmers
See other posts from Programmers
or by John Doucette
Published on 2012-10-18T13:32:44Z
Indexed on
2012/10/18
17:24 UTC
Read the original article
Hit count: 274
Doing R&D work, I often find myself writing programs that have some large degree of randomness in their behavior. For example, when I work in Genetic Programming, I often write programs that generate and execute arbitrary random source code.
A problem with testing such code is that bugs are often intermittent and can be very hard to reproduce. This goes beyond just setting a random seed to the same value and starting execution over.
For instance, code might read a message from the kernal ring buffer, and then make conditional jumps on the message contents. Naturally, the ring buffer's state will have changed when one later attempts to reproduce the issue.
Even though this behavior is a feature it can trigger other code in unexpected ways, and thus often reveals bugs that unit tests (or human testers) don't find.
Are there established best practices for testing systems of this sort? If so, some references would be very helpful. If not, any other suggestions are welcome!
© Programmers or respective owner