Edit: As Sebastian Bergmann told me via Twitter, PHPUnit already generate timing information into the JUnit XML logs, but the idea of this post is the earlier detection of slowness in tests, i mean, you are developing tests and you are executing them, thus you will detect quickly if the tests are exceeding a time limit.
The tests, in most of the cases, are written by developers. Sometimes, they don’t take care of the speed of those tests.
We, as test engineers, should detect, or even prevent, the slowness in tests.
PHPUnit let you use listeners to add logic in some parts of the test execution, therefore, you can detect when a test starts and finish.
The listeners are PHP classes that must implement the PHPUnit_Framework_TestListener interface, to use them you will need to create a XML configuration file passed as a param to the PHPUnit runner.
Type in your shell:
phpunit --configuration MyConfiguration.xml testsDirectory