Testing just saved my ass once more.
I had discovered that for some reason I was only catching about 70% of spam with my code. This worried me a lot. And I've been trying to figure out for a couple of days now what was wrong...
So today I wrote a test script that compared the parsing of mails using my custom mail parser with a different one. Turns out some subtle bugs were causing me to miss boat loads of email.
The good thing is the bug was in my test harness, not in the actual code, so while I found and fixed lots of interesting differences, I also managed to fix my test harness to give me the results I'm after.
In the process I got to use Test::More .
Things I like:
- More sensible function names than Test.pm's ok() functions
- is_deeply() - this rocks.
Things I didn't like much:
- I found it a bit convoluted to write tests where the number of tests depends on some external data source (e.g. in my case the number of files in a directory). Solutions range from BEGIN blocks to ->import tricks, but none are as simple as: plan tests => $var;
So all in all I prefer it to Test.pm, but I'm unlikely to use it unless I require it for some reason (such as is_deeply() in this case). Simply because I prefer to keep prereqs to a minimum where I can. Luckily this case is for an internal thing, so I can control the prereq's.
Anyway, kudos to Schwern (and anyone else who helped) for turning Perl into the most testable platform on the planet.
Update: D'oh. I meant Test::More. Of course I've used Test::Harness before. I'd be a fool to have over 50 CPAN modules and not used it