4 / 71 · 11 Manual Testing Fundamentals · Writing Test Cases← prev⊞ allnext →☰ Read as one page
1.4The Given/When/Then Template
GIVEN [precondition / system state]
WHEN [user action or trigger]
THEN [expected observable result]
This format, originating from BDD (Behavior-Driven Development), works even outside Cucumber or Gherkin frameworks. It forces you to separate setup from action from assertion.
Examples
GIVEN a registered user with an active account
WHEN the user enters valid email and password and clicks Sign In
THEN the user is redirected to /dashboard and sees a welcome message
GIVEN a shopping cart with 2 items totaling $50.00
WHEN the user applies discount code "SAVE10" (10% off)
THEN the cart total updates to $45.00 and the discount line is visible
GIVEN a user with no upload permissions
WHEN the user attempts to upload a file via the API
THEN the API returns HTTP 403 with message "Insufficient permissions"
When to Use Given/When/Then vs Traditional Format
| Scenario | Recommended Format |
|---|---|
| Agile team using BDD / Cucumber | Given/When/Then (mandatory) |
| Quick internal test documentation | Given/When/Then (concise) |
| Formal test plans for regulated industries | Traditional table format (detailed) |
| Exploratory testing charters | Neither — use free-form charters |