I've been playing with PHPUnit a lot of
late, particularly with
framework development.
One thing that's always hard to determine is how well your code is exercised
-- basically, how much of the code is tested in the unit tests?
In PHPUnit 3, you can now generate code coverage reports using
XDebug, and the usage is very simple:
matthew@localhost:~/dev/zend/framework-svn/tests$ phpunit --report ~/tmp/report AllTests
The above command creates a coverage report directory 'report' under my tmp
directory. You can then browse through the reports in a web browser and
visually see which lines of code were executed during tests, and which were
not, as well as a synopsis showing the percentage of coverage for any given
file or directory -- useful stuff indeed!
So, what's the problem? Getting XDebug running.
The executive summary:
For the detailed narrative, read on.