I'm trying to migrate from NetBeans to PHPStorm and the thing I cannot figure out is: how do I run my test suite for the current class (which ever that might be) without creating a run configuration for each class separately?
In NetBeans, you can run your entire suite with Alt+F6 or run the current class with just F6. This enables you to run just the tests you need and not your entire suite all the time which is obviously a time saver.
I cannot figure out how to do this in PHPStorm without creating a new run configuration for each and every class in the project which I obviously do not want to do.
First You have to tell PHPStorm where do You store your tests:
You can even right click on a single test method and choose "Run" (or Debug), Same for any test folder (if you have nested tests directories).
This thread helped me a lot and I was thankful for Jakub's answer however I had to do additional digging so I thought I would try to take it a bit further:
File > settings > Directories
File > Settings > Languages & Frameworks > PHP
File > Settings > Languages & Frameworks > PHP > PHPUnit
assuming your using composer select use Composer autoloader and set the path to yourprojectroot/vendor/autoload.php
or you can select Path to phpunit.phar and navigate to vendor/bin/phpunit, then check the box next to Default bootstrap file and make that the path to vendor/autoload.php
Open any phpunit test file in the editor and press CtrlShiftF10 to run it
Additional Tips: Since posting this and using the feature I learned a few more helpful things and thought I would just add them here:
In the project file explorer if you select any test directory or test file and do CtrlShiftF10 it will run that file or all test files in the directory.
ShiftF10 - will re-run whatever test you ran last, so if you are doing TDD and previously executed the test and you are working in the class being tested you can make a change and just press ShiftF10 after each change and it re-runs the previously run test, no need to select the test to re-run it.
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