Say, I have the following test:
[Test]
public void MyTest( [RandomNumbers( Count=100, Minimum=0, Maximum=1000 )] int number )
{
...
}
And at some point, during my regular build process, it has failed. I got an e-mail notification and set off to investigate.
Now, when I open the test in Visual Studio and click "Run Tests", it passes. I do it again, and it passes again. And again. And again. Obviously, the failure was related to that particular sequence of random numbers.
So the question is: How do I re-run this test with that exact sequence?
(provided I have full Gallio report)
UPDATE:
(following a comment about it being a bad idea)
First, I'm not actually asking whether it's a good idea. The question is different.
Second, when the system being tested is complex enough, and the input data space is of multiple independent dimensions, properly breaking that space into equivalency regions presents a significant challenge in both mental effort and time, which is just not worth it, provided smaller components of the system have already been tested on their own. At the same time, if I can just poke the system here and there, why not do so?
Third, I am actually not a newbie in this area. I always used this technique with other test frameworks (such as csUnit and NUnit), and it proved very successful in catching subtle bugs. At the time, there was no such concepts as generated data, so we used our own custom crutches, in the form of System.Random
with a predetermined seed. That seed was being generated as part of fixture initialization (usually based on current time) and carefully written to log. This way, when the test failed, I could take the seed from log, plug it into the test fixture, and get exactly same set of test data, and thus, exactly same failure to debug.
And fourth, if it is such a bad idea, why does the RandomNumbers
factory exist in the first place?