Data Tables, Scenario Outlines, Examples, and Parameter-Driven Test Design
Write expressive, reusable scenarios that cover multiple variations without duplicating entire feature files.
Inside this chapter
- Scenario Outline
- Data Tables
- When to Use Which
- Advanced Guidance
Series navigation
Study the chapters in order for the clearest path from beginner BDD concepts to advanced automation architecture. Use the navigation at the bottom of each page to move through the full tutorial series.
Scenario Outline
Scenario Outline: User logs in with different credentials
Given the user is on the login page
When the user enters username "<username>" and password "<password>"
Then the message "<message>" should be shown
Examples:
| username | password | message |
| valid | secret | Welcome back |
| invalid | wrong | Invalid credentials |
Scenario outlines are ideal when the behavior is the same but input variations differ. They reduce duplication while preserving readability.
Data Tables
Data tables allow structured input to be passed to steps, which is useful for forms, item lists, configuration values, and batch-like scenario data.
When the user fills the registration form
| name | Riya |
| email | riya@example.com |
| city | Kolkata | When to Use Which
Use scenario outlines when the whole scenario repeats with different examples. Use data tables when one step needs structured input. Good Cucumber authors know the difference and choose the approach that keeps scenarios easiest to read and maintain.
Advanced Guidance
Parameterization is helpful, but too much parameterization can make scenarios abstract and less readable. The goal is not maximum reuse at all costs. The goal is clear, executable behavior examples.