CakePHP v1.3: Full Code Coverage Report

399 Views Asked by At

In CakePHP v2.x, you can generate a unit testing code coverage report from the command line using a test suite that fires all of your app's tests and the --coverage-html option. (Example: cake test app All --coverage-html=tmp/coverage/)

I've been searching for an equivalent for Cake v1.3, which uses SimpleTest. When testing via the browser, it's possible to view code coverage for each individual test case, but not for the whole App category.

Similarly, running tests from the command line via cake testsuite app all does not seem capable of taking any command-line options for generating coverage output. The v1.3 Book doesn't dive into any more detail on the subject.

So my question is: Is there a way to generate a "full" code coverage report for a Cake v1.3 application from the command line?


Additional Information for future searchers:

Per @mark-story's suggestion, I tried running cake testsuite app all cov, but that produces the following fatal error for me:

PHP Fatal error:  Class 'CodeCoverageManager' not found in
    cake/tests/lib/reporter/cake_base_reporter.php on line 131

This is with SimpleTest v1.0.1 in my app/vendors/simpletest/ folder. I tried upgrading to SimpleTest v1.1.0, but that resulted in a different fatal error:

PHP Fatal error:  Call to undefined method CakeCliReporter::SimpleReporter() in
    cake/tests/lib/reporter/cake_base_reporter.php on line 85
1

There are 1 best solutions below

1
On

You might want to try addin 'cov' to the end of the cli runner arguments. The help() command indicates this will work. It has been a whilre, but I think this will output the % of code covered. There is no way to generate a detailed set of coverage reports like you can with phpunit.