Using PhpStorm for BDD with Codeception

Since some time Codeception also allows to write tests in Gherkin. This is a great addition to an already great tool.

When you do BDD you would also like to have a nice editor for your scenarios, which allows you to jump between steps and their step definitions, etc. A popular IDE for PHP is PhpStorm. And luckily the integration of Codeception has been announced:

But already now you can use the Gherkin features of the IDE to write your Codeception BDD scenarios:

  1. Install the Behat Support plugin.
  2. Get Behat and make it known to PhpStorm in the Settings: Languages and Frameworks —> PHP —> Behat
  3. Now you can add a new feature file ending with .feature.
  4. It will mark all steps as having an undefined step reference:
  5. If you go to such an undefined step, you can do an Alt-Enter, which offers you to create a step definition:
  6. Doing so creates a new file like this:

    You do not need to create step definitions like this, you can simply use any file if you take care that that file implements the Context interface.
  7. Now PhpStorm knows where the step references are, it looks in all files which implement the Context interface.
  8. In your feature file you can now CTRL-click on the step, and you are jumping to its step definition.
  9. For Codeception you still need to add the step definition file to the suite config.

That’s it!

Page 1 of 1, totaling 1 entries