A new documentation is available for Squash TM 2.0 and later versions, check it here
BDD test cases differ from classic test cases as they are based on a Gherkin synthax. They consist in keywords following by actions:
a key-word: Given, When, Then, And, But
an action
An action can be used by several BDD test cases, from the same project or not. The BDD test cases can be managed from the Action Word Library space which is available with the Action Word Library plugin. This plugin may for example, provide suggestions of actions when editing/modifying bdd test steps.
To add a new BDD test step, follow these steps:
Prerequisite: Having created a bdd test case
Select the BDD test case you wish to edit
Select the tab Test steps, on the “add a test step” box
Select a keyword in the drop-down list
Edit an action in the text field
Click [ADD] or press enter key
Each created test step will be added under the selected test step or at the bottom if no test step had been selected
The BDD test step’s action field is composed of:
fixed-parts: text
variable-parts: number or text in bracket “ “ or < >
An action must include at least one fixed-part and cannot exceed 255 characters.
For the fixed-parts, all characters are allowed except <, > and “ which are interpreted as parameter markers and the numbers which are automatically interpreted as variables.
For the variable parts of an action, the allowed characters depend on the nature of the variable. When the plugin “Action Word Library” is installed, the created actions and their test cases are displayed in the Action Word Library space.
The BDD test steps can be modified by clicking on the fields in the test steps table. It is possible to modify the keyword and the action, both the fixed and variable parts.
Following the modification of the action, the consequences are the same than for a creation: either a new action is created or a link is created with an existing action.
All characters are allowed except <, > and “ which are interpreted as parameter markers.
The deletion of BDD test steps works the same way as for classic test steps deletion.
It can be individual (via the button at the end of the line) or multiple (via the button [Delete] present above the table).
The test step deletion does not delete the action, it only deletes the link between the action and the test case. The action will still be displayed in the Action Word Library if the plugin has been installed.
An action includes fixed parts and variables parts also called “parameters”. There are two ways to add value to these variables:
with a value
with a test case’s parameter and datasets
It is possible to add a value within the test steps. The value will be read as a variable in the code, it can take any value and can differ from test cases to test cases.
To add a value in an action, it must be written in double quotes: “value”.
To add a test step including a parameter with a value:
Prerequisite: Having created a bdd test case
Tab “Test steps”, on the “add a test step” box
Select a keyword in the drop-down list
Edit an action in the text field
Click [Add] or press the enter key
The action is added to the test step tab. The parameter value (edited with double quotes) is displayed in blue without the quotes.
An action must include at least one fixed part, it cannot be composed of only a value. All characters are allowed in a value except “, > and <.
A second quote will be automatically added if the character “ is forgotten.
Numbers added in an action are considered as values, whether or not they are entered in double quotes. Therefore, they are automatically displayed in blue in the test steps of the BDD test case.
FOCUS
In the Action Word Library, the action that has the parameter with the value is displayed with a default parameter name “param1”, “param2”, “param3” (if there are several parameters). The value that was entered when creating the action becomes the parameter’s default value.
It is also possible to add a value to the action’s parameter with a parameter of the test case. This way, the parameter edited in the action can have several values defined in the datasets. To define a test case’s parameter, it must be written between < >: <value>. In a Gherkin script, the use of these parameters corresponds to a Scenario Outline.
To add a test step including a parameter carried by the test case:
Prerequisite: Having created a bdd test case
Select the BDD test case you wish to edit
Tab “Test steps”, on the “add a test step” box
Select a keyword in the drop-down list
Edit an action in the text field
Click [Add] or press enter key
The action is added to the test step tab. The parameter’s value (edited with <>) is displayed in <blue>.
A test case parameter cannot be empty and only upper and lower cases, numbers and - and _ are allowed. It is possible to modify an action in order to add a parameter with a value or a test case parameter. This modification will create a new action.
The test case’s parameters in between < > are listed in the Parameters tab. The ‘Parameters’ unit gives a list of the test case parameters. Each parameters are listed in the column header of the “Datasets” unit.
These parameters have to be valued by one or several datasets in the same way as a classic test case by clicking on the button [+] in the “Datasets” unit. When the test case will be included into an execution plan (Campaign Space), it will be added as many times as there are datasets.
To sum up, an action including one or more parameters can be used in two different ways:
Either the parameter is replaced by a value in the test step: "value"
Either the parameter is replaced by a test case parameter in the test step: <value>. This parameter will then be replaced by other values defined in datasets.
Each BDD test step has its own unit allowing to enter additional data. In Gherkin syntax these elements are the steps arguments and comments.
In order too edit the additional data of a BDD test step, follow these steps:
Prerequisite: Having created a bdd test case with a test step
Select the BDD test case you wish to edit
On the ‘Test Step’ tab, click on the arrow at the end of the line [>]
In this unit it is possible to edit:
a datatable
a docstring
a comment
These fields allow to add additional information to the action. The Datatable field allows to add value to the action. The table must comply with the following example:
The docstring field allows you to add multiline text which will be handled as an attribute of the action during automated execution. The comment field allows you to add comments to the action.
A button [Preview] is displayed on the Test step tab and allows to consult the script that will be generated by Squash when exporting or transmitting the BDD test case. The script structure depends on the technology and language configured in the project configuration. For the same BDD test case, the script will not be the same depending on the technology chosen: Cucumber or Robot Framework.
Given a test case including all the elements of the BDD test steps:
a parameter with a value
a test case parameter with 2 datasets
a datatable
a docstring
comments
Here are the scripts generated by Squash depending on the technology chosen:
The tag at the top of the script indicates the language of the script's keywords: # language: en.
The title of the feature, the scenario and the title of the BDD test case are the same.
Scenario Outline is displayed to indicate the presence of datasets.
In the test steps, the open parameters are in “ “ and the parameters of the test case are in < >.
Additional data is displayed under their respective test step.
Datatables are displayed between | |.
Docstrings are displayed in “ “.
Comments are displayed with a # at the beginning of each line.
When the test case has datasets, there are as many Example tables as there are datasets.
Each Example table is preceded by a tag with the name of the datasets (the spaces are replaced by _).
Datasets are displayed with the parameters name in the first line and the data value in the second line. The value with type string are in between quotes while numbers do not have quotes.
The “Resource” part is valued by squash_resources.resource.
The "Library" part is always valued by squash_tf.TFParamService.
The Gherkin keywords are always in English.
When the parameters of the actions have values, they are surrounded by " " in the script.
The action parameters valued by the parameters of the test case are represented by ${text} in the script.
The data tables’ and docstrings’ declarations appear before the scenario.
The data table and the docstring are displayed as follows: "${datatable}" and "${docstring}" on the test steps.
A docstring is not taken into account in the test step if a datatable is defined in the exact same test step.
The comment is displayed under the test step preceded by a #.
On a docstring, \t indicates a tab and \n a new line.