Scenario Outlines
A scenario outline is a parameterized scenario template. The scenario body contains <placeholder> tokens, and one or more Examples tables supply the values. Behave executes the scenario once per row, substituting the row values into the placeholders. This is the standard way to test the same behavior across many inputs without copy-pasting scenarios.
Basic Outline
Scenario Outline: Withdraw money
Given an account with <initial> USD
When I withdraw <amount> USD
Then the balance is <expected> USD
Examples:
| initial | amount | expected |
| 100 | 30 | 70 |
| 50 | 20 | 30 |
| 10 | 5 | 5 |
Multiple Examples Tables
Outlines may have several Examples tables, which helps document distinct groups of cases, such as normal values and edge values:
Examples: happy paths
| initial | amount | expected |
| 100 | 30 | 70 |
Examples: limits
| initial | amount | expected |
| 20 | 20 | 0 |
| 20 | 19 | 1 |
Implementing the Steps
By execution time the placeholders are already replaced, so the steps are ordinary parameterized steps:
from behave import given, when, then
@given("an account with {amount} USD")
def step_impl(context, amount):
context.balance = int(amount)
@when("I withdraw {amount} USD")
def step_impl(context, amount):
context.balance -= int(amount)
@then("the balance is {amount} USD")
def step_impl(context, amount):
assert context.balance == int(amount)
When to Use Outlines
Use an outline when the steps are identical and only the data changes. If a case needs different steps or extra assertions, write a standalone scenario instead. Adding a regression case later is then trivial: add one table row and the suite covers it.
Summary
Scenario outlines combine a template scenario with Examples tables. Each row becomes one execution, placeholders arrive in the steps as plain strings, and the result is compact, data-driven testing of a single behavior.