Each time I run unit tests of one class or the entire folder, phpunit generates coverage for the entire system because it is configured in phpunit.xml.
This is bad because it takes longer and runs out of PHP memory.
My phpunit.xml
<phpunit backupGlobals = "false" backupStaticAttributes = "false" colors = "true" convertErrorsToExceptions = "true" convertNoticesToExceptions = "true" convertWarningsToExceptions = "true" processIsolation = "false" stopOnFailure = "false" syntaxCheck = "false" bootstrap = "Bootstrap.php" > <testsuites> <testsuite name="Application Module Suite Test"> <directory>./Module1Test</directory> <directory>./Module2Test</directory> <directory>./Module3Test</directory> </testsuite> </testsuites> <filter> <whitelist> <directory>../module/Module1</directory> <directory>../module/Module2</directory> <directory>../module/Module3</directory> </whitelist> </filter> </phpunit>
Is there a way to generate coverage of just what I'm testing right now, dynamically ?
Example
For the command below, I would like to generate coverage only for the Controller/ExampleController.php .
phpunit Controller/ExampleController.php --coverage-html ~/Desktop/tests
I am using PHPUnit 4.8 and 3.7, Sublime Text Editor and the application uses Zend Framework 2.
php phpunit zend-framework2
Edson horacio junior
source share