The Codeception test framework is a nice way of organizing your Unit, Integration and Acceptance tests under one roof, and PhpStorm 2017.1 brings support for Codeception into your favorite IDE.
While Codeception uses PHPUnit under the hood to run its tests, it’s been fiddly (at best) to get Codeception tests to run quickly and easily in PhpStorm, until now. PhpStorm 2017.1 brings a Codeception specific test runner that makes it much simpler to configure your Codeception test runner, and to run specific batches of tests right from within your IDE.
First, we need to tell PhpStorm where to find the Codeception executable on our system. In my case, I’ve installed Codeception using Composer, so it’s in the
vendor\bin folder. You can find these settings under Languages & Frameworks | PHP | Codeception.
Next, we just create a run configuration using the Codeception type from the run configuration drop-down menu in the toolbar. The easiest way to configure the runner is by using the Type option – you can run just your Acceptance, Integration or Unit tests, or run all tests. I’m running just the Acceptance tests.
If you only want to run the tests in the file that you are in, you don’t need to create a full configuration. If Codeception is configured correctly in PhpStorm, you can just right-click anywhere in the file and select Run, and then click the filename with the Codeception logo next to it.
Now, we can run the test using either the play button next to the configuration drop-down or by using the CTRL+R shortcut. As with the other test runners, we get all the benefits of running tests inside PhpStorm, including click-through to failed or skipped tests. It’s also worth noting that like all the test runners in PhpStorm, the Codeception runner works for both local configuration and remote configurations (including Vagrant and Docker).
I’ve started playing with Codeception again after a number of years not using it, and it seems to have improved a lot since I last looked at it. I’m looking forward to working with Codeception in PhpStorm. As with all the improvements, give it a go, and let us know what you think.
– Gary & The PhpStorm Team