Posts

Showing posts from June, 2011

Code coverage in Perl

To get code coverage percentage :


/usr/perl -MDevel::Cover <perl scripts> <arguments>

The code coverage database will be stored at a directory called :


cover_db/

It will report out how many percentage hit per run. If you would like to view the total percentage hit result, you'll need to use another command :


/usr/bin/cover

This will report out the overall hit result. However, somehow I can’t' find which line of my perl scripts has not been hit to put more test for my test suite.

Example output :

----------------------------------- ------ ------ ------ ------ ------ ------ File stmt branch cond sub time total ----------------------------------- ------ ------ ------ ------ ------ ------ hello2.pl 90.9 50.0 n/a 100.0 100.0 85.7 Total 90.9 50.0 n/a 100.0 100.0 85.7 ----------------------------------- ------ ------ ------ ------ ------ ------

Another way of doing this, but this doesn't report the hit in percentage, but list out how many hits on each "effective"…