PyCharm 2023.3 Help

Create step definitions

Creating step definition

If a .feature file refers to a non-existent step, PyCharm recognizes and highlights such a step, and provides an intention action that helps create the missing 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.

  2. Hover over the highlighted symbol or press Alt+Enter and select Create Step Definition.

    Undefiden step in .feature file
  3. Select the target step definition file from the list:

    Selectubg the target file to create the step

    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 Control+Space after keywords. Note that you can narrow down the suggestion list by typing characters contained anywhere within a description. 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:

    Code completion for step in .feature files
  • You can find usages of a step definition. To do that, place the caret at the desired definition, and press Alt+F7. For more information, refer to Find usages in a project.

Last modified: 15 January 2024