Like Geoffrey Young I only recently discovered the wonder that is Devel::Cover. I used it today to "check the tests" for a new Perl module I was writing. In the process of writing more tests to get better coverage I managed to uncover a few bugs. Yay.
It also had another interesting effect on my code writing. Seeing all the conditionals and occasionally branches I couldn't get my tests to reach made me simplify a lot of my "defensive" statements.
I am using Module::Build to build, test and so on. When running "perl Build test" to get the coverage metrics I'd get metrics for the Build script as well, which I wasn't interested in. It took me some trial and error to figure out how to pass the proper parameters to Devel::Cover. A comma between parameter and argument did the trick.
PERL5OPT=-MDevel::Cover=-ignore,Build perl Build test;
cover -report html -outputdir /home/ask/public_html/tmp/coverage
On a related note, Pod::Coverage via Test::Pod::Coverage is brilliant to check if you got all your public methods and functions documented. Too bad it can't parse if the documentation makes any sense. :-)
update: see also How to misuse Code Coverage (PDF).
Damn that's cool. Of course now I've got a huge list of things I need to add tests for, but still, damn cool.
Since you're using Module::Build now, have you seen that Apache::Test now supports Module::Build, thanks to the new Apache::TestMB module?
David,
Yeah, I saw that you put it up. Very cool! I am definitely going to check it out next time I'm writing tests for an Apache module.
- ask