tbhaxor's avatar

Unable enable coverage in unit tests

I am running tests with xebug.mode set using php

php -dxdebug.mode=coverage  ./artisan test -p --coverage

It runs the tests, and after passing I see warnings

 WARN  No code coverage driver is available.

   WARN  Unable to get coverage using Xdebug. Did you set Xdebug's coverage mode?

It only works when I set environment variable XDEBUG_MODE=coverage. I am OK with this approach, but want to learn why it didn't work with the first approach given here XDEBUG_MODE does same thing as setting via php -dxdebug.mode=coverage?

0 likes
2 replies
Merklin's avatar

Modify phpunit.xml. As an example, this is the one I use:

The <source> determines which folders to be covered in the coverage and which folders to be excluded.

Regarding x-debug, excluding the debug mode is not good if you or your editor use it, but you can stack the options like xdebug.mode=debug,coverage at the end of php.ini.

Please or to participate in this conversation.