Autorun PHPUnit Tests in PhpStorm 2017.2

In recent versions of PhpStorm we’ve tried to make improving the testing experience a priority, and in 2017.2 we’ve done just that by introducing the ability to automatically run PHPUnit tests when you stop editing.

The ability to autorun tests has been a hot topic of discussion on Twitter and at conferences and user groups for a long time. There’s been a workaround using file-watchers for a while, but PhpStorm 2017.2 brings you the ability to autorun tests after you’ve stopped editing files integrated into the test runner.

To start your tests automatically running, run your tests, as usual, (using a run configuration – you can find more information in this video), and then turn on auto-testing by using the Toggle auto-test button.

phpunit-auto-toggle

This turns on autorunning of tests 3 seconds after you stop editing any file (excluding scratch files). You can change the time it takes for the autorun to fire using the Set AutoTest Delay menu you can find in the More options (cog) menu.

phpunit-test-delay

It’s also worth mentioning that we’ve unified the place you configure your test frameworks, be that PHPUnit, PhpSpec, Behat or Codeception. If you want to create a configuration for a test framework you’ll now find them all under Languages & Frameworks | PHP | Test Frameworks rather than in their own individual settings section. You still create each configuration in the same way as before, however.

We hope you enjoy this new feature, I’m already using this in some of my open source work and it’s really useful – give it a try and let me know what you think.

– Gary & The PhpStorm Team

About Gary Hockin

Gary Hockin has been creating code to power web applications for 15 years, the last three of them at an extraordinary level. He is handsome, talented, funny and articulate, and also extremely modest. Gary is a valued contributor to Zend Framework 2 and is a member of the community review team. He's married and has two wonderful children, and when he's not coding, writing about code, speaking about code or reading about code, he can usually be found in the pub playing pool.
This entry was posted in Cool Feature, Newsletter and tagged . Bookmark the permalink.