Assuming following feature file
Feature: demo for a key,value data table
Scenario: duplicate data for a scenario
When some condition is true
Then enter a valid data pair
|Key |value|
|Key |value|
|SomeKey|SomeValue|
and you want to execute the scenario for all listed rows, regardless the duplicated row Key,value
.
The step can be implemented using a DataTable parameter
public void enterAValidDataPair(DataTable dataTable) throws Exception {
System.out.println("dataTable.raw().size() = " + dataTable.raw().size());
for (List<String> row : dataTable.raw()) {
System.out.printf("key: %-10s value: %-10s%n", row.get(0), row.get(1));
}
}
if you run the scenario the method produces following output
dataTable.raw().size() = 3
key: Key value: value
key: Key value: value
key: SomeKey value: SomeValue