in reply to Philosophical question about testing
Very nice write-up by pemungkah above.
Just wanted to add one more thing: when you challange a test with a lot of different inputs I recommend defining the input and expected output in a data structure, such as an array of hashes like this:
Now it becomes much easier to test all those different cases in a loop that creates each of those files, gives it the permissions and maybe writes some content into it and then runs the tests for file validity and/or repairability (is that even a word?) on each one in turn without having to copy and paste the test code for each case.my @tests = ( { desc => "a file with wrong permissions can be repaired", test_file => { { permission => "111", contents => "some string" }, is_valid => 0, is_repairable => 1, }, { desc => "an invalid file that can not be repaired throws an error" + # ADD DATA HERE } );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Philosophical question about testing
by rastoboy (Monk) on Nov 01, 2010 at 17:51 UTC |