Given When Then
ELI5 — The Vibe Check
Given When Then is AAA's cousin from the BDD world. Given = the setup situation. When = what the user/system does. Then = what should happen as a result. It reads more like a user story, which is why product managers can actually understand it.
Real Talk
Given-When-Then is a semi-structured way to write test scenarios, originating from BDD. Given describes the initial context, When describes the action or event, Then describes the expected outcome. It maps naturally to Gherkin syntax and makes tests double as documentation.
Show Me The Code
// Using Gherkin
Given a user has 3 items in their cart
When they apply coupon 'SAVE10'
Then the total should be reduced by 10%
And a success message should be displayed
When You'll Hear This
"Write acceptance criteria in Given-When-Then so QA can convert them directly to tests." / "Given-When-Then scenarios become runnable Cucumber tests."
Related Terms
AAA Pattern (AAA)
AAA stands for Arrange, Act, Assert.
BDD (BDD)
BDD is like writing your tests in plain English so your non-coder boss can also understand them.
Behavior-Driven Development (BDD)
Behavior-Driven Development is about describing HOW your app should behave before you build it — using language that makes sense to everybody, not just cod...
Test Case
A test case is one specific scenario you want to check. 'Does the login work with a correct password?' — that's a test case.