PyCharm 2016.3 Help

Creating Step Definition

This feature is supported in Professional edition only.

On this page:

Overview

If a .feature file refers to a non-existent step, PyCharm's code inspection recognizes and highlights such step, and provides an intention action that helps create missing step definition.

Creating step definition

To create a missing step definition

  1. While editing the .feature file, type a reference to a step definition. PyCharm highlights step as undefined, and gives detailed information at the tooltip:
    cucumberUndefinedStepInspection
  2. Press Alt+Enter to show the Create Step Definition intention action:
    cucumberCreateStepDefinition
  3. Select the target step definition file from the pop-up list:
    /help/img/idea/2016.3/py_createUndefinedStep.png

    You can either select one of the existing step definition files from the suggestion list, or create a new one.

    PyCharm creates a step definition stub in the specified location.

  4. In the selected step definition file that opens in the editor, enter the desired code.

Tips and tricks

  • While typing, use code completion Ctrl+Space after keywords. Note that you can narrow down the suggestion list by typing characters contained anywhere within a description. So doing, on top of the suggestion list there will be the variants that contain specified characters as prefixes, followed by the variants with the arbitrary occurrences of characters:
    /help/img/idea/2016.3/py_gherkinCodeCompletion.png
  • You can find usages of a step definition. To do that, place the caret at the desired definition, and press Alt+F7. Refer to the section Finding Usages in Project for details.
  • PyCharm keeps an eye on the uniqueness of the step definitions. Step definitions with the same names are highlighted.
    /help/img/idea/2016.3/py_duplicatedStepDefinition.png

See Also

Last modified: 23 December 2016