Good stuff for programming geeks
[ start | index | login or register ]
start > 2005-02-19 > 1

Start/2005-02-19/1

Created by tmoertel. Last edited by tmoertel 2021 days ago. Viewed 1518 times. #2
[diff] [history] [edit] [rdf]
labels
attachments
coverage-summary.png (11113)

On the road to LectroTest 1.0: testing and code coverage

In preparation for a big release, I spent quite a few hours beefing up the test suite for LectroTest. I added 41 new tests, an increase of 16 percent. Some of the tests were tricky to write, and I spent way more than 16 percent of my testing effort on these last few tests.

But the results of the effort were worth it: 100 percent coverage. According to the Perl code-coverage tool >>Devel::Cover, the tests in the suite now cover 100 percent of LT's statements, branches, conditions, and subroutines. I sure do like seeing green on the summary report.

coverage summary report

The new tests uncovered one obscure bug, which I fixed. They also uncovered some crufty code that I should have cleaned up earlier and had forgotten. Now the cruft is gone.

In a few places I had to refactor the code to eliminate impossible conditions that were throwing off the coverage report. For example, consider the code below, in particular the portion in bold face.

if ($content && s/(.*)/binding($1)/es) {
    $content .= " $1";
}

The coverage tool indicated that I was not testing the case in which the regex op in the second part of the if condition fails to match. The reason, of course, is because it cannot fail; the regex (.*) always matches. So I rewrote the code to remove the regex op from the condition:

if ($content) {
    s/(.*)/binding($1)/es;
    $content .= " $1";
}

Problem solved.

For the most part, however, when Devel::Cover said that there were holes in my testing, they were real holes. Having filled those holes, I now have the confidence in LectroTest that I need to feel comfortable about recommending its widespread use.

And that's step one on the road to a big 1.0 release.

no comments | post comment
community.moertel.com | Copyright © 2003–07 Moertel Consulting