When running PHPunit there are only dots and letters for each test by default:
To enable debug output and get some more details about the tests running, simply add the logging section to
<log type="testdox-text" target="php://stdout"/>
This will create a debug output and helps to track the tests:
In my case, this helped when my code reached an infinite loop due to an error. This results in a RuntimeException without any outputs or log messages. The process just ended with:
The process has been signaled with signal "11".
When using PHPUnit there are different ways to create a code coverage report. By default, XDebug is used. But as mention on different sites, XDebug is very slow and the generation of a code coverage report might take several minutes for big projects.
To speed up things,
can be used. This significantly speeds up unit tests and code coverage.
can be used as follows:
phpdbg -qrr ./vendor/bin/phpunit --coverage-text --colors=never
But there are different problems with the code coverage report of phpdbg. For example
does not cover a case line of a switch statement:
A better solution to cover this is
, which can be installed using
To create a code coverage report, phpunit can be called with:
php -dpcov.enabled=1 -dpcov.directory=. ./vendor/bin/phpunit --coverage-text
To exclude a directory, the following parameter can be used:
php -dpcov.enabled=1 -dpcov.directory=. -dpcov.exclude="~vendor~" ./vendor/bin/phpunit --coverage-text
I don’t know if it’s really a problem with pcov, but: with
pcov installed, it is not possible to use phpdbg anymore!