Quickly Run PHPUnit Tests in PhpStorm

Quickly Run PHPUnit Tests in PhpStorm

PhpStorm has loads of features and it’s extremely powerful, however, it can be difficult finding new options that will speed up workflow. A few months ago we covered a Sublime Text Package for automatically running your PHPUnit tests and by using a keyboard shortcut it drastically reduces the time it takes to run them.

The way the package works is if you are in a test method it will run PHPUnit with just that method tested, if you are in a class it’ll test the whole class, and finally a shortcut to run the entire suite.

I didn’t think a feature like that was possible in PhpStorm but Jonathan Williamson proved me wrong and here is a video he made with instructions on how you can set it up:

Here are the text directions that are taken from that video:

Go to PhpStorm preferences, then keymap and search for “Run Context Configuration” which has the default of ctrl + shift + r. Change it to suit your needs.

Next, still in preferences, go to Languages and Frameworks -> PHP -> PHPUnit and set that up for your project. Each setup will be unique so if you need help here visit the PhpStorm docs.

Finally, in your test class, you can now use that shortcut for running the test in the method your cursor is in, or the class file you have open.

Filed in: Development Tools / PhpStorm / PHPUnit


Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Lead Front End Developer
Full-Stack Laravel Developer
Revive Interior
Intermediate PHP Developer (Full Stack | CakePHP | Laravel | Vue | jQuery)
Senior PHP Developer (Full Stack | CakePHP | Laravel | Vue | jQuery)
Laravel Developer
Amsterdam (partially remote possible)
Let's Book
Web Developer (Laravel)
Tweed Heads, New South Wales, AUSTRALIA
Tursa Employment & Training
Laravel Experts needed-Remote position
Golden Sky ROI