CHAPTER 20 ■ CONTINUOUS INTEGRATION
In order to use this feature you must have the Xdebug extension installed. You can find more about
this at http://pecl.php.net/package/Xdebug (installation information at
http://xdebug.org/docs/install)..) You may also be able to install directly using your Linux
distribution’s package management system. This should work for you in Fedora 12, for example:
$ yum install php-pecl-xdebug
Here I run PHPUnit with code coverage enabled.
$ mkdir /tmp/coverage
$ phpunit --coverage-html /tmp/coverage test
PHPUnit 3.4.11 by Sebastian Bergmann.
.....
Time: 0 seconds, Memory: 5.25Mb
OK (5 tests, 6 assertions)
Generating code coverage report, this may take a moment.
Now you can see the report in your browser. See Figure 20–2.
Figure 20–2. The code coverage report
It’s important to note that achieving full coverage is not the same as adequately testing a system. On
the other hand, it’s good to know about any gaps in your tests. As you can see from Figure 20–2, I’ve still
got some work to do.