liveBook · Manning

Examples table

As explained in Effective Behavior-Driven Development

A Gherkin block containing the example data used to generate scenarios from a scenario outline.

An Examples table supplies the data that turns a Gherkin scenario outline into multiple concrete scenarios. It helps keep similar scenarios readable in one place, while showing the variations that matter. section 8.4 section 8.4.2

The table follows the Examples keyword. Its header names correspond to angle-bracket placeholders in the outline; each non-header row supplies values for one generated scenario. Columns not used as placeholders are ignored, so a description column can explain why an example matters without changing the scenario. section 8.4.2

Listing 8.6 Scenario outline
Scenario Outline: Describe what remains of a pizza
  Given a diner cuts their pizza into <slices per pizza> slices
  When they eat <slices eaten> slices
  Then they should have <remainder> slices left

  Examples:
    | description       | slices per pizza | slices eaten | remainder |
    | Not hungry at all | 6                | 0            | all       |
    | Quite hungry      | 6                | 4            | 2         |
    | Very hungry       | 8                | 8            | none      |

The pizza example shows three rows producing three scenarios, with a description column providing context for readers. section 8.4.2

Use examples tables to communicate meaningful variations, not simply to accumulate rows:

  • Choose examples that clarify distinct behavior; repeated or duplicate rows add little value. section 8.4.3
  • Keep tables readable and concise. Large tables with many low-value examples can make patterns hard to spot and slow automation. section 8.4.3

How Effective Behavior-Driven Development covers it

How deep it goes
Explains header matching, row substitution, and ignored columns, then discusses example value; does not detail automation implementation.
Examples
Uses pizza slices and order contact details to illustrate scenario variations, and duplicate rows to show the cost of bloated tables.
What you can do after
Apply Gherkin Examples tables to expand a scenario outline into concrete scenarios with selected data variations.
How it connects
Connects examples tables to Gherkin, scenario outlines, and feature files.

Also explained in

Compare how 2 books explain examples table →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Behavior-Driven Development. The section links point to the parts of the book it draws on.