Scenario Shaping
Use this reference when requirements are underspecified, bug reports mix symptoms with guesses, or a feature request needs to be broken into small Given/When/Then scenarios.
Scenario Template
Use one concrete rule per scenario:
Given <relevant starting state>
When <single trigger>
Then <observable outcome>Good scenarios are:
- Observable
- Small
- Deterministic
- Free of implementation detail
Start With The Simplest Example
Choose the smallest example that proves the rule.
Examples:
- Empty cart gets free-shipping banner removed
- Invalid token returns 401
- Duplicate username is rejected
- Archived record is hidden from active lists
Only add richer fixtures after the simplest example is covered.
Slicing Heuristics
Split the behavior when the story contains:
andin theWhen- Multiple outcomes in the
Thenthat can fail independently - Setup that does not matter to the rule being tested
- UI narration that hides the actual business rule
Prefer:
Given a suspended account
When the user signs in
Then access is deniedOver:
Given a suspended account with three pending invoices and a profile image
When the user opens the app, clicks Sign In, submits email and password, waits for redirect, and opens billing
Then access is denied, invoices stay pending, and a warning banner is shownBug Regression Template
Turn bug reports into this shape:
- Remove any guessed cause from the scenario.
- Keep only the triggering conditions.
- State the expected outcome and the actual wrong outcome.
- Write the expected outcome as the new test.
Example:
- Report: "CSV import crashes when a row has a blank date because the parser assumes ISO strings."
- Scenario:
Given an import row with a blank date
When the import runs
Then the row is rejected with a validation error instead of crashingAcceptance Criteria Template
For feature work, derive:
- One happy-path scenario
- One validation or gating scenario
- One edge case if the domain obviously demands it
Example:
Given an unpublished draft
When an editor clicks Publish
Then the draft becomes publicly visible
Given a draft missing a title
When an editor clicks Publish
Then publishing is blocked with a title-required messageNaming Tests
Prefer names that state behavior, not implementation:
rejects_blank_dates_with_validation_errorshows_free_shipping_only_above_thresholdblocks_publish_when_title_missing
Avoid names like:
test_parser_handles_case_3calls_validate_then_saveworks_correctly