Code coverage for XP using XDebug. Based on Sebastian Bergmann's Code coverage library.
$ composer global require xp-forge/coverage
Next, make sure you have the XDebug Zend extension loaded via zend_extension
.
$ xp coverage -p src/main/php/unittest/ src/test/php
[.....................]
♥: 21/21 run (0 skipped), 21 succeeded, 0 failed
Memory used: 3839.68 kB (4050.93 kB peak)
Time taken: 0.246 seconds
Coverage: 84.72% lines covered (61/72)
┌──────────────────────────────────────────────────────┬─────────┬──────┐
│ Class │ % Lines │ Not │
╞══════════════════════════════════════════════════════╪═════════╪══════╡
│ unittest.coverage.ClassName │ 100.00% │ │
│ unittest.coverage.CoverageDetails │ 100.00% │ │
│ unittest.coverage.CoverageListener │ 60.71% │ 11 │
└──────────────────────────────────────────────────────┴─────────┴──────┘
An optional HTML report can be generated like this.
$ xp coverage -p src/main/php -r ./coverage-report src/test/php/
Use it in order to find out how to improve your coverage.
A clover report can be generated as well.
$ xp coverage -p src/main/php -c clover.xml src/test/php/