Getting Coverage Statistics in Perl

Please note: This tutorial assumes the system running perl is running ActivePerl: Standard Distribution. If this is not the case, please make the appropriate system-specific substitutions. If you are unable to use this tutorial with the distribution or system configuration required by your sponsor, please contact the testing manager.

You will need to download several packages to add onto your distribution of perl to be able to gather coverage statistics and write unit tests. To add functionality to perl, open a command prompt and type "ppm" as shown in the figure below:

Now press Ctrl-P and go to the "repositories" tab. Under "suggested" select "Trouchelle" and click "Add" as shown in the figure below.

In the search box at the top of the PPM GUI window, you can search for the required packages. Then, right click on the package you want, and go to "Install ____" where ____ is the name of the package you want as shown in the figure below.

You will need to repeat these steps for the following packages:

When you have finished telling ppm the full list of packages you wish to install, go to "File -> Run Marked Actions". ppm's status will appear in the bottom section of the GUI window. Once the packages are installed, you can continue on to writing a test.

Getting Coverage Statistics in Perl

First, save the following code a file named somewhere in your code directory:

use Test::Extreme;
print "Hi there!\n";
if (4==3)
	print "This should not work!";
	print "Maybe it's not enough to make a difference!";
	print "We'll be here";
assert (4==4);
print "Something else";

Now open a command prompt and change directories to where is located. Execute the command perl -d:Cover The test should execute. From the same directory, type cover to generate an HTML file indicating the test coverage for