Recently we started a new API application in CakePHP 2.2 and put some code and unit tests. When we put the code in Jenkins CI to a continuous integration we setup the code coverage and in the reports we got couple CakePHP core files as not covered.

Our application doesn’t care about cover Cake files, and we also don’t want to include Cake core tests in our CI . Leaving these files in CI give reports that our code is not well covered, which it is not true and hide the uncovered code from our app.

As CakePHP, we also use PHPUnit in other project, but there we use the phpunit.xml configuration file. Using the configuration file is easy to put folders/files on black and white lists, but it is not possible when using CakePHP because it has their own runner system. Our solution was figure out a way using code. We changed our test suite to do it, see below.

The code is available on https://gist.github.com/3260166

With the code above you can run in your console: ./Console/cake test app AllApp --coverage-html=./report