We have not figured out how to integrate PHPUnit well into our projects, especially when CI’s unit test library is so handy. However, I did take the time to try using PHPUnit’s CodeCoverage metric. However, in order to get it to work, I had to blacklist the CI system directory (the application directory is outside the system directory). It took some debugging, but here is how to do that.
To black list a directory:
$filter = new PHP_CodeCoverage_Filter; $filter->addDirectoryToBlacklist('/path/to/system'); $filter->addDirectoryToBlacklist('/path/to/app/logs'); $coverage = new PHP_CodeCoverage(null,$filter);
You have to create a new CodeCoverage_Filter object, add the blacklisted directories, then pass that object to the PHP_CodeCoverage constructor.
I still want to determine why I had to blacklist the system directory. But until then, this is good and generating the reports I am looking for.