To use variables on a BDD test case
An action consists of fixed and variable parts, also called 'parameters'. To use variables with a BDD test case, these variable parts can be valued in two different ways in the test steps:
- By free values
- By test case's parameters and datasets
With free values
Interpreted in the code as variables, free values can adopt any value and differ from one test case to another.
To define a free value in an action, it must be written between quotation marks: "value".
An action must contain at least one fixed part, so it cannot be composed only of a free value. All characters are allowed except ", < and > that must be escaped by a \ . \ can be escaped itself.
Numbers specified in an action are considered as free values, whether or not they are enclosed in quotation marks. They are automatically displayed in colour blue in the test steps of the BDD test case.
If the Action Library plugin is installed, in the Action words workspace, the action containing the parameter with a free value is displayed with a default parameter name: "param1", "param2", "param3" (if there are several parameters in the action). The free value that was entered when the action was created from the test case becomes the default value of the parameter. The name and the default value of the action parameter can be modified from the Action words workspace but their modification has no impact on the values already entered in the test steps.
For more information, please visit the page Conceive Automated Tests
With parameters and data sets
The variable parts of an action can also be valued by test case parameters. When running the test case, the parameter specified in the test step action can thus adopt the values defined in the test case datasets.
To define a test case parameter in an action, it must be written between the <> characters. This is referred to as a "parameter carried" by the test case.
A test case parameter cannot be empty and only uppercase letters, lowercase letters, numbers and dashes - and underscores _ are allowed. It is possible to modify an action already present in the test case to add a parameter with a free value or a test case parameter. This modification will result in the creation of a new action.
If the Action Library plugin is installed, in the Action words workspace, the action containing the test case parameter is displayed with a default parameter name: "param1", "param2", "param3" (if there are several parameters in the action).
The test case parameter between <> that was entered at creation from the test case is not taken as the default value of the action word's parameter.
For more information, please consult the page Conceive Automated Tests
The parameters specified in <> are automatically listed in the Parameters and Datasets anchor of the test case. These parameters are destined to be variabilized by one or more data sets in the same way as for a classic test case.