Skip to content

Commit

Permalink
Add example with parameterized Scenario Outline
Browse files Browse the repository at this point in the history
When using a Scenario Outline it is possible to use a placeholder in the
name of that Scenario Outline. The resulting pickle will have the
placeholder replaced with a value from the example tables.

This allows us to test use cases where this matter such as:
- cucumber/junit-xml-formatter#34
- cucumber/testng-xml-formatter#4

Fixes: #96
  • Loading branch information
mpkorstanje committed Jun 21, 2024
1 parent 971ca50 commit 49198a6
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 66 deletions.
20 changes: 18 additions & 2 deletions devkit/samples/examples-tables/examples-tables.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
Feature: Examples Tables
Sometimes it can be desirable to run the same scenario multiple times with
different data each time - this can be done by placing an Examples table underneath
a Scenario, and use <placeholders> in the Scenario which match the table headers.
different data each time - this can be done by placing an Examples table
underneath a Scenario, and use <placeholders> in the Scenario which match the
table headers.

The Scenario Outline name can also be parameterized. The name of the resulting
pickle will have the <placeholder> replaced with the value from the examples
table.

Scenario Outline: Eating cucumbers
Given there are <start> cucumbers
Expand All @@ -25,3 +30,14 @@ Feature: Examples Tables
| start | eat | left |
| 12 | banana | 12 |
| 0 | 1 | apple |

Scenario Outline: Eating cucumbers with <friends> friends
Given there are <friends> friends
When there are <start> cucumbers
Then each person can eat <share> cucumbers

Examples:
| start | friends | share |
| 12 | 11 | 1 |
| 4 | 1 | 2 |
| 4 | 0 | 4 |
Loading

0 comments on commit 49198a6

Please sign in to comment.