Applies to TestComplete 14.0, last modified on January 24, 2019

In the Gherkin editor, you can view and edit BDD test scenarios.

Open the editor

  1. Switch to the Project Explorer panel (if it is hidden, select View > Project Explorer from the main menu of TestComplete).

  2. Double-click any child node (feature node) of the Scenarios project item. TestComplete will open the editor in the Workspace panel:

    Open the Gherkin editor

Editor contents

Here is a sample view of the editor:

Gherkin editor

Click the image to enlarge it.

The feature file starts with the Feature: keyword followed by the feature description. The description can be multiline. The lines should not start with a Gherkin reserved keyword like Given, When, and so on.

Feature typically corresponds to a subsystem or some larger functionality of the tested product. Below the feature description, you have a definition of one or multiple usage Scenarios to test.

The Given, When, and Then lines below Scenario are called test steps. You can automate them with TestComplete. For more information on this, see Create Test Step Scripts.

If needed, you can insert comments (# comment text) into the feature file and add tags to scenarios and features (@tag-name).

For more information on writing scenarios and on Gherkin keywords, see Gherkin Syntax in TestComplete.

Generate script code

To generate script functions for a test step, right-click somewhere within the editor and select Generate Step Definitions from the context menu, or click Generate Step Definitions on the toolbar:

The Generate Test Steps command

Click the image to enlarge it.

The generated code has function definitions and special statements that link script functions to test steps (see Binding Script Functions to Test Steps). The script commands that simulate mouse clicks, keyboard events, and other actions should be created or recorded by QA engineers. For more information on creating these script functions, see Create Test Step Scripts.

If some test step already has a script function linked to it, a new function is not generated. If all the steps have script functions linked to them, the “Generate Step Definitions” item is disabled.

Navigation to script code

To jump to a script function linked to a test step:

  • Simply press Ctrl and click the test step description:

    Jumping to the script function linked to a test step

    – or –

  • Right-click the test step and select Go to Definition from the context menu:

    Jumping to the script function linked to a test step

Other editing features

The features the Gherkin editor offers are similar to the features of the Script editor. The Gherkin editor supports:

  • Outlining. You can collapse and expand text blocks.

    See how it works

  • Quick indentation. This is helpful when you need to align test steps quickly.

    See how it works

  • Smart formatting. Whenever you type a quote, opening bracket or brace, the editor automatically enters another quote, closing bracket or brace.

The Gherkin editor also supports some other features of the Script editor like group undo, automatic indents, and some other.

The Editing settings of the Script editor control the behavior of the Gherkin editor. To view or change these settings, select Tools > Options from the main menu and go to Panels > Code Editor > Editing in the subsequent dialog, or click Panel Options on the Gherkin editor’s toolbar.

Run features, scenarios, and steps

To run a feature, scenario or an individual test step, right-click the feature, scenario or test step line and select Run This Feature File, Run This Scenario, or Run This Test Step from the context menu:

Running BDD tests from the Gherkin editor

Click the image to enlarge it.

Note that test steps depend on earlier test steps and on the tested application state, and they might fail when running outside their scenario. The same concerns scenarios, because in general, they might depend on earlier scenarios. So, we recommend using these Run ... commands for debugging purposes only. To run your BDD tests on a regular basis, use other means that TestComplete offers.

One possible way to run BDD tests is to make them test items of your project and run them as part of your project run. To append a scenario to test items, right-click the scenario in the editor and select Add Scenario to Test Items from the context menu:

'Add Scenarios to Test Items' menu item


Item Description

Generate Step Definitions

Generates script functions for Given, When and Then test steps. See above.

The item is disabled if the feature, scenario or test step descriptions violate the Gherkin syntax.

Decrease Indent and
Increase Indent

Change the indent of the current line or block of code.

Hide Selected Lines and
Stop Hiding Current Block or Selected Lines

Collapse the selected block of text or expand a collapsed block. See Outlining.

Navigate Back and
Navigate Forward

Switch between previous and more recent locations of the insertion point.

Panel Options

Opens a dialog box with editor options.

Further reading

See Also

Behavior-Driven Development (BDD) With TestComplete

Highlight search results