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:
- Install the Behat Support plugin.
- Get Behat and make it known to PhpStorm in the Settings: Languages and Frameworks —> PHP —> Behat
- Now you can add a new feature file ending with .feature.
- It will mark all steps as having an undefined step reference:
- If you go to such an undefined step, you can do an Alt-Enter, which offers you to create a step definition:
- 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.
- Now PhpStorm knows where the step references are, it looks in all files which implement the Context interface.
- In your feature file you can now CTRL-click on the step, and you are jumping to its step definition.
- For Codeception you still need to add the step definition file to the suite config.