Data Tables
@DataTable and @ForEach
Since v2.47.0
Consider the following example step containing a data table.
When the following items are added
| Item |
| Get the milk |
| Walk the dog |
This example defines a single column table containing a header followed by two entries.
A StepDef could be defined to process each row of data in the table as follows:
@DataTable
@ForEach
@StepDef
Scenario: the following items are added
Given the todo field can be located by class "new-todo"
And my todo list can be located by css ".todo-list"
When I enter Item in the todo field
Then my todo list should contain Item
This StepDef
will be executed for each row of data in the table (2 times in this example)
The @DataTable
and @ForEach
annotations work together to process each record in the data table. When the feature step is evaluated, Gwen will call the StepDef for each record in the table and bind each field value to its declared name in the header record. The last two steps in this example will enter each Item
into a todo field
and check that it was added to my todo list
.
Implicit attributes
The following attributes are also implicitly available to data table StepDefs: