/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" line.
/usr/bin/perl -d:Coverage <perl scripts> <arguments>
This will store the result into a special file, no special report or output on the screen from the run is expected.
<perl scripts>.cvp
To view the result :
/usr/bin/coverperl <perl scripts>.cvp
This will list out the effective line number and how many hits on the runs that you have fired.
Example output :
3 line 5 1 line 7 1 line 8 1 line 13 1 line 15 1 line 17 1 line 18 0 line 21 1 line 24
Note :
- You must put full path of your perl scripts if you run on other directory, else the coverage database will not be created.
- Details can be found at http://search.cpan.org/~pjcj/Devel-Cover-0.78/lib/Devel/Cover.pm