July 4, 2004 Archives

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).

About this Archive

This page is an archive of entries from July 2004 listed from newest to oldest.

July 2, 2004 is the previous archive.

July 20, 2004 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.3-en