As test writers, when we see code with poor test coverage the most natural approach is to think that we ought to write more test cases, indeed we have been doing exactly that for PHP. The number of test cases for the PHP implementation has increased from roughly 3000 to 5000 over the past two years.
But - there is another way, and as usual the PHP core developers are showing us the way. The fastest way to improve percentage of code covered is to REMOVE UNTESTED CODE! Accordingly we saw the test coverage of PHP 5.3 increase from about 55% to a little over 70% over the summer of 2008. At the same time the lines of code in PHP dropped by about 50KLOC. How can this be?
To be serious, what's been done is perfectly legitimate. Several libraries that are used in, but not tested by, the PHP project have been removed from the statistics, they should probably never have been included in the PHP5.2 figures. The only misleading thing is that if you don't look closely you might think that PHP5.3 was a lot better tested that PHP5.2, in fact it's a bit better tested and we still need more tests.
Coverage of 70% looks good, but the goal 2009 PHP TestFest should be 80% coverage to be achieved by writing more tests!
Friday, 14 November 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment