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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |