Summer Sale! All accounts are 50% off this week.

Wojtek-R's avatar

Pest coverage output in console with PhpStorm

Hello!

I am using Pest to test my laravel application with PhpStorm. I have also installed xdebug on my machine and i can confirm that by php -v. I can get test coverage if I run it in PhpStorm clicking on "run with coverage", but when I try to run ./vendor/bin/pest --coverage I do not get Pest console log. I have tried adding xdebug.mode=coverage to php.ini file but it doesn't seems to work. Not sure what am I doing wrong..

0 likes
10 replies
Sinnbeck's avatar

Have you tried waiting? Mine just does nothing for a little while, and then suddenly gives output

Sinnbeck's avatar

@Wojtek-R So nothing happens and you need to stop it with ctrl+c? Or it just exits ?

Sinnbeck's avatar

@Wojtek-R Ok so you get the test output. I thought you got nothing at all. So after the last test it exists.

Can you try this from the docs

XDEBUG_MODE=coverage ./vendor/bin/pest --coverage
1 like
Wojtek-R's avatar

Okay, it finally worked! it seems that it only outputs the coverage in the console log when there is no failed tests.. something that should be mentioned in documentation. Thanks to @sinnbeck for directing me in the right direction

Sinnbeck's avatar

@Wojtek-R Yeah thats how coverage works :) I dont know if it is mentioned in the phpunit docs somewhere. Pest is just a wrapper for that

1 like
Wojtek-R's avatar

@Sinnbeck That makes sense, but it does work with failed tests in phpStorm coverage window on run with coverage giving you all the data.

Sinnbeck's avatar

@Wojtek-R It could be due to how phpstorm handles the data, or the fact that phpstorm uses another output driver (teamcity if I recall correctly) :)

Edit: Just checked and it is indeed teamcity

./vendor/bin/pest --coverage --teamcity

Be aware that the output is for programatic usage. It might not be usable for you :)

1 like
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Ok did a bit of testing. It is done by phpstorm by adding the flag --coverage-clover ./path/to/output.xml. This dumps the coverage report to that file, even though phpunit does not output it :)

Anyways. If the issue is solved, you can close the thread by marking a best answer

Please or to participate in this conversation.