I have set up PhpStorm 5 with PHPUnit, and I'm curious if PhpStorm might have some functionality that will automatically run a unit test when saving a file. Like watchr and guard. I have tried search our beloved www and the PhpStorm docs, but haven't been able to find a solution for it.
Rerun a single testRight-click a test on the Test Runner tab of the Run tool window and select Run 'test name'.
In eclipse, you go to test class-> right click -> run-> as junit. Somewhat like this we do. Its similar in intellij too. Go to test class right click and run as junits.
As of version 6, PHPStorm has "File Watchers"
<custom>
You will have to set up a command line for PHPUnit, it wont be the integrated testing, but you can have errors output to the console (which is good a good start!)
Various macro options are available to you, so you can include (for example) $FileNameWithoutExtension$Test.php
in the arguments passed to your command line.
I personally had to set up two watchers. The first detected modifications to project files, and the second detected changes to test files (the second did not append Test.php
to the filename) I also created a new project scope to exclude the tests directories from the first watcher.
You may also want to turn off immediate synchronisation, as this causes PHPUnit to run when PHPStorm auto-saves files.
My other settings are like:
PHP files (PHP)
Project excluding tests
/path/to/php
/path/to/phpunit --configuration /path/to/phpunit.xml.dist /path/to/tests/$FileNameWithoutExtension$Test.php
$FileDir$
$FileDir$
No output filters set, syntax error checks enabled, and console showing errors.
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