how to test when correct output is "random"?

phil hunt philh at cabalamat.org
Sat Apr 5 17:27:43 CEST 2003


On Fri, 4 Apr 2003 15:53:13 -0600, Jeff Epler <jepler at unpythonic.net> wrote:
>
>But other parts are based on randomness.  "Alternation rules" are the
>foundation on which this is built.  An alternation rule might read
>like this:
>    S: "a" | "b" | "c";
>Then, str(S) would yield one of the alternatives.  Over many runs, it
>should yield each choice about an equal number of times.  So how do
>I test this?  Run a large number of trials and do a statistical test?
>This doesn't seem to fit in with the philosophy of software testing,
>which stresses exact repeatability.

If your code exhibits randomness, it obviously won't output the same 
value every time. All you can do is test the values are reasonable: 
statistical test are good. Also, check values are within legal 
ranges, so for example a dice throw would have to be an integer from 
1 to 6.

-- 
Philip Hunt <philh at cabalamat.org>

Interested in adventure holidays in Spain? 
Look at: <http://www.cabalamat.org/advcon/>




More information about the Python-list mailing list