andy at hexten.net
Mon May 14 23:57:26 BST 2007
On 14 May 2007, at 23:23, Nicholas Clark wrote:
> I'm always surprised that so few people seem to do this. Often
> people I work
> with write tests, and each is/like/... runs once. I like putting
> them in
> loops or subroutines and feeding them data until they refuse even a
> thin mint. Having this style of battery of tests has often exposed
> corner cases due to the range of data tried.
The regression test for Perl::Version started out as a little REPL
that I typed variously formatted version strings into. It captured
and displayed the output. Every time I noticed an inconsistency I
probed with some more tests around the same area. Then I dumped all
the captured inputs and outputs, manually corrected the erroneous
outputs and wrapped the resulting data with a little test driver.
If I'd written the tests longhand I don't think I'd have been
anything like as exhaustive.
And if I wanted to port the code to Python or Ruby I'd only have to
rewrite the 'driver' bit of the test - the data would remain the same.
Andy Armstrong, hexten.net
More information about the london.pm