Friday, 29 December 2006

Using Xdebug and PHPUnit3 for code coverage analysis

I've tried compiling Xdebug (both from a source download and through PECL) on my PowerBook before, but I've always had problems. Today, however, it finally worked. I also installed the latest release of PHPUnit (version 3.0.0 stable) after running with both PHPUnit2 and 3.0.0alpha11 (the last PEAR release) for a while.

Changing the PHP_CodeSniffer unit tests to support PHPUnit3 was harder than I anticipated, probably due to the fact that I was constructing my test suites in an "interesting" way. But it didn't take long, and with Xdebug now installed (thanks to a little help from this article) I was able to start generating code coverage reports for PHP_CodeSniffer.

I have to say that I am impressed by the code coverage reports that are generated. They really are quite good and make it very easy to see which directories, files and lines require additional testing. I'm also pleased to say that the coverage analysis for PHP_CodeSniffer is quite high, although I still have a few places that need testing.