Codeception Support Comes to PhpStorm 2017.1

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.

codeception-settings

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.

codeception-run-settings

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.

codeception-run-anim-2

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

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, Early Access Program, Newsletter, PhpStorm and tagged . Bookmark the permalink.
  • AlexGemmell

    Great job! We’ve been hoping you’d get around to this for a while! I look forward to trying it out.
    More and more development is done with locally run virtual containers. Is there any different instructions to run Codeception tests inside a docker instance?

    • Maxim Kolmakov

      There is no difference in setting up Codeception and PHPUnit in Docker so you can follow the following tutorial: https://blog.jetbrains.com/phpstorm/2016/11/docker-remote-interpreters/
      To summarise, you need to create PHP remote interpreter based on docker image, create new Codeception configuration based on that remote interpreter and then run your tests as usual.
      If there are any problems please contact our support team (Help->New Support Request…).

  • Nate Sanden

    So excited to try this out! Codeception is an amazing Framework.

  • David Cochrum

    Kudos for the much anticipated integration. My only complaint now is the inability to generate coverage via Codeception the same as PHPUnit.

  • https://au.linkedin.com/in/tapani108 Lauri Jalonen

    Got a test env set up in 10 mins. Now running push-button acceptance tests straight off my code view. Many thanks, @geeh!