0Pricing
Testing Mastery: JUnit, Mockito & Integration Tests · Lesson

Scenario Outlines and Data Tables

Drive a single Gherkin scenario with multiple data sets using Scenario Outlines, Examples tables, and inline data tables.

Scenario Outlines and Data Tables is a free Testing Mastery: JUnit, Mockito & Integration Tests lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Testing Mastery: JUnit, Mockito & Integration Tests learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Repeating Scenarios

Often you want to run the same behavior with different inputs. Copy-pasting a scenario per case is wasteful. Gherkin's Scenario Outline parameterizes one scenario over many examples.

Placeholders with Angle Brackets

In a Scenario Outline, values are placeholders written in angle brackets, filled in from an Examples table.

Scenario Outline: add numbers
  Given I enter <a> and <b>
  When I add them
  Then the result is <sum>

The Examples Table

The Examples keyword introduces a table of rows. Each row runs the outline once with those values.

  Examples:
    | a | b | sum |
    | 2 | 3 | 5   |
    | 0 | 0 | 0   |
    | 5 | 7 | 12  |

How It Expands

Cucumber expands the outline into one concrete scenario per Examples row, substituting the placeholders. Three rows means three test runs.

Step Definition Receives Values

The step definition uses capture groups, and each expanded row supplies its values.

@Given("I enter {int} and {int}")
public void enter(int a, int b) {
  this.a = a; this.b = b;
}

Data Tables vs Outlines

An Examples table multiplies the scenario. A data table passes a structured argument to a single step.

Given the following users
  | name | role  |
  | Ada  | admin |
  | Bob  | guest |

Consuming a Data Table

The step receives the table, which you can convert into a list of maps or domain objects.

@Given("the following users")
public void users(DataTable table) {
  List<Map<String,String>> rows =
      table.asMaps();
}

Choosing the Right Tool

Use a Scenario Outline when the whole flow repeats with varied inputs. Use a data table when one step needs a collection of structured data.

Keeping Examples Readable

Name columns clearly and keep each Examples table focused. Large unfocused tables hide which behavior you are actually specifying.

Multiple Examples Blocks

You can have several Examples blocks under one outline, each with a tag or comment, to group happy-path and edge cases.

Why It Matters

Parameterized scenarios keep features concise and make boundary testing explicit and reviewable by non-developers.

Quick Check

What does each row of an Examples table produce?

Recap

You learned data-driven Gherkin:

  • Scenario Outline uses <placeholders> and an Examples table
  • Each row runs the scenario once
  • Data tables pass structured data to a single step
  • Pick outlines for repeated flows, data tables for collections

Frequently asked questions

Is the “Scenario Outlines and Data Tables” lesson free?

Yes — the full text of “Scenario Outlines and Data Tables” is free to read here on the web, and the Testing Mastery: JUnit, Mockito & Integration Tests course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Testing Mastery: JUnit, Mockito & Integration Tests course, upgrade to CoddyKit PRO.

What will I learn in “Scenario Outlines and Data Tables”?

Drive a single Gherkin scenario with multiple data sets using Scenario Outlines, Examples tables, and inline data tables. You practise Testing Mastery: JUnit, Mockito & Integration Tests with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Testing Mastery: JUnit, Mockito & Integration Tests?

No prior experience is required. Testing Mastery: JUnit, Mockito & Integration Tests on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Scenario Outlines and Data Tables” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Testing Mastery: JUnit, Mockito & Integration Tests lesson?

Yes. Every Testing Mastery: JUnit, Mockito & Integration Tests lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Introduction to BDD
  2. Gherkin Syntax and Features
  3. Implementing Step Definitions
  4. Scenario Outlines and Data Tables
← Back to Testing Mastery: JUnit, Mockito & Integration Tests