PHPUnit 4.7 and Three Shades of Green

Sebastian Bergmann |

PHPUnit 4.7 introduces a couple of small improvements. For instance, PHPUnit's PHPT test runner now supports --INI-- sections, information about the PHP runtime used is now printed in verbose mode, and a warning is now printed when code coverage data is collected but no whitelist is configured.

Small, Medium, or Large?

To bridge the time while you're waiting for me to finish the support for branch and path coverage, I implemented a small improvement for the HTML-based code coverage report. It now uses different shades of green depending on whether a line of code is covered by large tests (light green), medium tests (medium green), or small tests (dark green). These different shades of green will make it obvious when a line of code, for instance in an action method of a controller class, is only covered by an edge-to-edge test. To leverage this feature, simply annotate your tests with @small, @medium, or @large.

This feature is the second to utilize the @small, @medium, or @large annotations. They were originally introduced for use with the test execution timeout check that marks a test as risky when it takes more to time to execute than allowed. PHPUnit will soon be able to (optionally) mark a small test as risky when the code under test performs I/O operations, for instance.

Looking Ahead: PHPUnit 5

PHPUnit 5, scheduled for release in October 2015, will only be supported on PHP 5.6 and PHP 7. As PHPUnit follows Semantic Versioning the major version number must be incremented when the minimum required version of PHP is increased. Functionality that is marked as deprecated in PHPUnit 4 will be removed in PHPUnit 5.

PHPUnit 4.8, scheduled for release in August 2015, will be last release series of PHPUnit to support PHP 5.3, PHP 5.4, and PHP 5.5. PHPUnit 4.8 will receive bug fixes until August 7, 2016.

About the author

Sebastian Bergmann

Sebastian Bergmann is the author of PHPUnit and sets the industry standard of quality assurance.