Cucumber | Difference between Examples Table & Data Table
2 min readMar 27, 2019
* Examples Table:
Feature: Learn data tableScenario Outline: Cucumber Data Table
Given Table with example
| FirstName | <FirstName> |
| MiddleName | <MiddleName> |
| LastName | <LastName> |Examples:
| FirstName | MiddleName | LastName |
| Priyank | B | Shah |
| Mansi | P | Shah |
- The
Scenario Outline
keyword can be used to run the sameScenario
multiple times, with different combinations of values. Scenario Outline
is run once for each row in theExamples
section beneath it (not counting the first header row).- This works for the whole test
- Cucumber automatically run the complete test the 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.
* Data Table:
Sample 1:Given the following tic tac toe board:
| x | | |
| o | x | |
| x | | o |Sample 2:Given user is logged in to application
| username | admin |
| password | admin123 |
- No keyword is used to define the test data
- 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
* So What To Use When?
- 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.