Conceive Automated Tests
Reminders on BDD Test Cases
BDD test cases are different from classic test cases due to the structure of their test steps. BDD test steps are based on Gherkin syntax. They contain two things:
- a Keyword: Given, When, Then, And, But;
- an Action: an action sentence following the keyword.
It is possible to use Gherkin test cases to start automation but BDD test cases have more advanced features.
You can access the Actions Library workspace with the "Actions Library" plugin. This plugin is part of the Squash AUTOM Premium License.
The Actions Library offers two main features:
- Manage actions used by BDD test cases;
- When writing BDD test steps, get suggestions of available actions in the projects on which you are authorized.
Every project has its own actions library. But one action can be used by test cases from different projects.
Action Consultation Page
On an action's consultation page, there are 4 blocks:
- The "Information" block contains the project's name and the action's description.
- The "Parameters" block enables you to manage the action's parameters
- The "Test Case Using the Action" block enables you to view the information on the test cases that use the action. By clicking on the name of the test case, its consultation page appears.
- The Implementation block appears the information related to the action's implementation.
- The "Technology" column indicates which implementation technology is set up at the level of the Squash TM project of the test case using the action the last time that test case switched to the "Automated" status.
- The "Last implementation date" column indicates the date when a test case using the action switched to the "Automated" status for the last time.
View an Action from the Test Cases Workspace
From the "Test steps" tab of a BDD test case, you can directly access an action's consultation page by clicking on the button [...], then on "View Action":
You can only click on this option if you have an authorization for the project containing the action.
When clicking on this option, the action appears on a level-2 page. If you have the necessary rights, you can edit the description and modify the content of the "Parameters" block. The "Information" block indicates the project containing the action.
Manage an Action's Parameters
The block "Parameters" on an action's consultation page enables you to manage its name and the default value of its parameters. This block can be different depending on how the action was created.
When creating an action with a parameter from the Actions Library:
- The name of the parameter is automatically entered in the "Parameters" block;
- The default value is empty.
Unless the name of the parameter is a number. In that case, please see below.
When creating an action with a parameter with an undefined value from the Test Case Workspace:
- The name of the parameter is automatically replaced by a generic value ("param1", "param2", etc.)
- The undefined value entered at the test step level is automatically entered as the parameter's default value.
You can modify the name and the default value of the parameter in the "Parameters" block:
- For the name of the parameter, only uppercase and lowercase letters, numbers, dashes - and underscores _ are allowed;
- For its default value, every character is allowed except for <, > and ".
These two fields have a 255 character limit minus the number of characters already in the action's fixed parts.
When the Actions Library plugin is installed on Squash TM, action suggestions are activated when you create or modify BDD test steps.
How Suggestions Work
When you create or modify a test step, suggestions for actions already in the projects you are authorized on appear as you type. Words are predicted based upon the fixed parts of the action; the word order has no consequences on the suggestions that are made.
You can navigate between the different suggestions using arrow keys of your keyboard. To select a suggestion, click on it or on [Enter]. To add the selected action to the test case, click on [Enter].
Action Suggestions Across Projects
The actions suggested when you create or modify a BDD test step are the actions that already exist in the projects on which you have reading rights.
There are three specific cases:
- The action suggested is both in the current project and in other projects;
- The action suggested is only in one other project;
- The action sugested is in multiple other projects.
1st Case: When the action suggested is both in the current project and in other projects, it is the action that is in the current project that will be linked to the test case.
2nd Case: When the action suggested is only in one other project, it is that action that will be linked to the test case.
3rd Case: When the action suggested is in multiple other projects, a popup appears to enable you to choose the action's project that will be linked to the test case.
Give a Value to a Suggested Action's Parameter
Within test steps, an action's parameter can be valued with an undefined value. This value is interpreted in the code as a variable. It can be anything and be different from one test case to another.
To define an undefined value in an action, you must write it in between quotes: "Value".
An action's parameter can also have as a value one of the test case's parameters. Thus, the parameter entered in the test step's action can have multiple values all defined in the test case's datasets.
To define a parameter of the test case in an action, you must write it in the parameters <>: <value>.
In Gherkin syntax, the use of these parameters implies that it is a Scenario Outline.
Once you have selected a suggested action, you can modify its parameter in the input field and replace it either by an undefined value between "" or by one of the test case's parameters between < >. This modification will be specific to the test case. This test case will be linked the suggested action even if the parameter is modified.