Devstack » Articles » Code-Coverage Analysis with Apache2::ASP

Code-Coverage Analysis with Apache2::ASP

If you are unfamiliar with the idea, "code-coverage testing" is about writing unit tests, then running them with Devel::Cover and viewing the output.

The summary generally will look something like this:

Devel::Cover with Apache2::ASP

From this screen you can drill down deeper to view exactly which lines of code were executed, which were not executed, and so on.


As you can see from this example, I need to write more tests if I am to achieve 100% coverage for this website.

To aggregate the code coverage from your entire collection of unit tests, run the following commands (or place them inside of a nice shell script):

cover -delete
HARNESS_PERL_SWITCHES=-MDevel::Cover prove -r t/
cover

A new directory named cover_db will be there and inside of it, the file coverage.html

Copy all of the *.html and *.css files someplace where you can view them in your browser (i.e. - under htdocs/coverage) and navigate to coverage.html to view your code coverage report.