One way to approach this would be to ascertain what coverage you currently have and then keep writing tests until you have satisfactory coverage. Devel::Cover can help with this. For example, here are the first few lines of a table that lists the sort of coverage you would get:

File stmt branch cond sub pod time total
/dp/usr/cxp/code/util_src/rtk_test/web_test 81.2 36.7 43.5 80.0 n/a 54.8 60.4
/home/cxp/code/th_web_tests/perl_lib/Aliased.pm 44.4 50.0 n/a 12.5 n/a 0.4 34.0
/home/cxp/code/th_web_tests/perl_lib/RTK/Class/MethodMaker.pm 73.7 72.7 n/a 55.6 n/a 1.5 71.6

I've left in the hyperlinks, but I changed them so that they don't actually go anywhere. Were you to actually generate such a report, those hyperlinks would go down into line-by-line detail pages that show you exactly what is and is not getting covered. You'll even find truth tables that show you which conditions of a logical expression are getting used!

By reading through Devel::Cover::Tutorial, you can learn what those headings mean. Generating such a report is easy. Here's how I did it:

perl -MDevel::Cover /usr/local/bin/web_test -d -h # wait a while for the tests to finish cover cover_db -report html

I number at the far right is a loose estimate of the percentage of code coverage. It's also fair to note that there are a few bugs in this code (it's alpha code, after all). That report came up fine the first time that I ran it. The second time, I found that the index file had been named .html, making it invisible with a standard ls. I had to rename it to index.html and copy it to the cover_db/ directory to get it to work properly.

Despite a few bugs, it's very easy to work with and can give you a nice idea of how complete your coverage is. Since the html is generated through Template Toolkit, you might even be able to auto-generate a few tests with this ...

Cheers,
Ovid

New address of my CGI Course.


In reply to Re: Automated Path Coverage Test Case Generation by Ovid
in thread Automated Path Coverage Test Case Generation by ChrisS

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.