Use variables with a Gherkin Script
Using variables with a Gherkin script enables you to replay a scenario as many times as the number of datasets it contains.
To introduce variables to a Gherkin script, you need to use different keywords, parameters, and datasets directly integrated in the script. The keyword "Scenario plan" indicates that the scenario contains examples, in other words parameters and datasets.
In the script, the parameters are defined by being written in between the characters < and >. There can be as many parameters as you want. Then, these parameters must be inserted into a database.
Before inserting a database, the keyword "Examples" must appear so as to indicate the existence of this database. The database is in the form of a table with as many columns as there are parameters in the script. This table's heading contains in each column the name of the parameters as written in the script. Each row corresponds to a dataset that will be played during the execution.
Focus
The name of the parameters in the heading of the datatable must be written the same way as they are in the script. The letter cases must be the same too, otherwise the parameters will not be taken into account and will not be displayed during the execution.
During the execution, for an automatic execution, the script is automatically replayed for each dataset. For a manual execution, a test step is created for each dataset in the execution. In the execution plan, contrarily to BDD test cases, there is not one ITPI per dataset, but only one ITPI in total. During the execution of this ITPI, the execution scenario displays as many test steps as there are datasets in the script's data table.