erdfisch Blog

Use test coverage via xdebug directly in phpstorm

Single image: 

This small blog post will show how to run unit tests in storm and directly access the test coverage based upon that.

If you want to use the shell, have a look at the following post…

Setup phpunit in phpstorm provides a short help how to run the tests in phpunit. Ensure that you have read that post and setup like that.

Run coverage in storm

Once that was done you have a small little icon next to the phone (listen to xdebug connections).

Clicking this runs all the tests and then parses the result of phpunit/xdebug. (this may take a while).

Look at the result

Once it is done you can open a random file, (ViewExecutable.php in this example) and see how much of the code is tested by looking at the file, see screenshot.

Red is code which wasn't executed while running the tests and green lines are covered.

In general you should avoid reading your code while writing tests but this gives you a good indication whether you have missed something.

Please provide feedback.

Blog gallery