scenario outline and data table code example
Example: scenario outline and data table
Scenario Outline vs Data Tables
The Scenario Outline keyword can be used to run
the same Scenario multiple times,
with different combinations of data set.
Scenario Outline runs for each row in the
Examples section beneath it (not counting the first header row).
This works for the whole test
Cucumber automatically runs the complete
test number of times equal to the number
of data in the Test Set.
Example tables always have a header row,
because the compiler needs to match the header
columns to the placeholders in the Scenario Outline’s steps.
No keyword is used to define Data Table
This works only for the single step, below which it is defined
A separate code is need to understand
the test data and then it can be run
single or multiple times but again just
for the single step, not for the complete test
Data tables are passed wholesale to the
step definitions, and it's up to the user to
interpret them. They don't necessarily have a header row:
* When To Use What?
Use Example Table where ENTIRE scenario
needs to be tested with different/multiple test data.
Use Data table where test data is Explicitly meant
for specific steps and user would like to interpret
based on use case internally.