I am trying to run unit test in PhpStorm with codecoverage. It throws me a error msg saying interpreter is missing. How to install the interpreter!
Also how to configure in order to run my tests with code coverage.

Steps to do:
File -> Settings -> Languages & Frameworks -> PHP
Select your PHP version. Then click button with ... (three dotes), then add interpreter.
https://www.jetbrains.com/phpstorm/help/interpreters.html
File -> Settings -> Languages & Frameworks -> PHPUnit
a) Load form include path
To add this you must set where PHPUnit library is installed. Then add using External Libraries in Project.

To specify path use green + button.
b) Use custom autoloader
Use this option when you install PHPUnit via composer. In Path to script field specify autoload file.
https://www.jetbrains.com/phpstorm/help/phpunit.html
In the top right corner use Select Run/Debug Configuration menu

And click Edit Configurations. Select green + button to add PHPUnit.

Define name of the configuration and directory with tests. Additionally you can add some PHPUnit arguments in Test Runner options field.
https://www.jetbrains.com/phpstorm/help/run-debug-configuration-phpunit.html
Tests sometimes needs to use a bootstrap file which set environments, loads configs etc. To set this file go to:
File -> Settings -> Languages & Frameworks -> PHPUnit
and select the bootstrap file in Default bootstrap file field.

https://www.jetbrains.com/phpstorm/help/phpunit.html - in Bootstrap file section.
To run with coverage you must install Xdebug PHP extension. You should read the Xdebug installation guide.
After this actions use a icon

to run with coverage.
https://www.jetbrains.com/phpstorm/help/code-coverage.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With