One thing I do a lot is run unit tests. And it seemed PhpStorm wasn't quite able to work in my setup, Probably because I thought too complicated, actually it works fine.
Running a single test case
The recommended way of running a test is to simply run it with the context menu in the editor or project view. But we need to define an autoloader so the tests can run. Ok, no problem with a run configuration, but... you need to specify a directory or file. So, what if I simply want to run the current test? Simple, actually:
- Specify the XML configuration for PHPUnit in the default run configuration for PHPUnit (ignore anything else)
- Run any test (a temporary configuration will be created automatically)
The latter is also slightly simpler than I thought, as e.g. NetBeans has a "run test" command, PhpStorm tells scripts and tests apart on it's own.
Running all tests
Running all tests is not possible with that approach, as there is no single test root folder for all tests. But it's still easy, as the XML configuration defines a pattern for all tests already. So simple create a run configuration manually (it should already know the XML file from above) and select the XML file option. Running that configuration will execute all tests defined therein.
Open issues
Of course a few things are not really cool for now.
- A major issue is the missing support for code coverage, but that is being worked on already.
- Then having an option to filter not only passed tests from the output, but also differentiate between skipped/incomplete/fail/error - please...
- Navigate between test and code, as requested already.
- And it would be cool if the test result browser would group tests in a useful way - at least when running a lot of tests using XML configuration that is not the case.
Leave a reply