Does anyone know of a way to achieve this or do they think it's a good idea. To have an OR style syntax in Gherkin for reducing repetition but maintaining human readability (hopefully). I'm thinking of cases where clause combinations are expanded with every combination of multiple OR statements. e.g.
Scenario: TestCopy
Given Some text is selected
When The user presses Ctrl + C
OR the user right clicks and selects copy
OR the user selects Edit + Copy
Then the text is copied to the clipboard
This would run as 3 tests each with the same given and then but with one When from the OR set. I guess this could have been acheived using a template with a place holder for the When clause but I think this is more readable and could allow the OR to be used in the Given as well to produce n x m tests. With the outline you would still need n x m rows.
Thanks.
You can generatd multiple tests from one scenario with Scenario Outlines:
Scenario Outline: TestCopy
Given Some text is selected
When <Copy operation executed>
Then the text is copied to the clipboard
Examples:
| Copy operation executed |
| The user presses Ctrl + C |
| the user right clicks and selects copy |
| the user selects Edit + Copy |
In a Scenario Outline
you basically create a template which is filled in the with the provided Examples
.
For the the above example Specflow will generate 3 tests with the same Given
and Then
and with the 3 different When
s:
When The user presses Ctrl + C
When the user right clicks and selects copy
When the user selects Edit + Copy