In TestComplete, you can create BDD scenarios by writing their Gherkin code in the TestComplete Gherkin editor.
1. Create project items
In TestComplete, BDD scenarios are located in Feature files that are child items of the Scenarios project item:
You start creating scenarios by adding these items to your project.
-
Add the Scenarios project item to your TestComplete project. To do this:
-
Right-click your project in the Project Explorer and select Add > New Item from the context menu.
-
In the subsequent dialog, select Scenarios and click OK:
If the Project Explorer panel is hidden, select View > Project Explorer from the main menu to make it visible.
-
-
Add a Feature item to Scenarios:
-
Right-click the Scenarios node in the Project Explorer and select Add > New Item from the context menu.
-
In the subsequent dialog, select the Feature type, specify a name and click OK:
TestComplete will add the new Feature item to the project and will open its editor.
-
2. Write Gherkin code
After you create a Feature project item, you can create scenarios. You write them in the Gherkin language in the editor of the Feature item:
For information on keywords and syntax, see Gherkin Syntax in TestComplete.
3. Automate test steps
After the scenario is ready, automate it, that is, create script code that will simulate the needed user actions.
-
To start faster, right-click somewhere within the Gherkin editor and select Generate Step Definitions from the context menu, or click this item on the editor toolbar:
This will command TestComplete to generate script functions for test steps (
Given
,When
,Then
,And
,But
). The generated code also has statements that link the generated functions to test steps. -
Record or write manually script code for the generated functions. See Create Test Step Scripts.