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 Ctrl Shift F10 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 Ctrl Shift F10 it will run that file or all test files in the directory.
Shift F10 - 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 Shift F10 after each change and it re-runs the previously run test, no need to select the test to re-run it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.