Gherkin and executable examples
Write a key example in Given, When and Then lines so that people can read it and a tool can run it as a check. Learn what the analyst writes and what the developer adds.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: A recipe that a kitchen robot can follow. A recipe for a person can say "cook until it looks right". A robot cannot follow that. Its recipe must say exactly: heat the pan, add two eggs, wait three minutes. The robot does each step in order and tells you if one fails.
Gherkin is a plain-text way to write examples in Given, When and Then lines that people and tools can both read. An is an example written so exactly that a tool can run it as a check. A is the small piece of code that tells a tool what to do for one example line.
Sam, the for the Daily List app, has an example from a talk with Nina, the : a viewer cannot change a shared list. He writes it in Gherkin. Leo, the developer, connects each line to the app. From then on, the example is a check that runs every time the app changes.
The robot picture has a limit. Gherkin text is not executable by precision alone. Code must bind the steps and make meaningful assertions. A vague step can even pass if its code checks nothing, so review what the automation actually proves.
PLAIN WORDS · 3 in this section
- pan
- a wide cooking dish used on a stove
- gherkin
- a plain way of writing examples; also a pickled cucumber
- executable
- able to be run or carried out
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the work.
THE REAL JOB The picture helps a newcomer remember that an must be exact enough for a machine, and that a vague step can match a weak assertion.
- Name the scenario
- Write the Given
- Write the When
- Write the Then
- Connect each line to code
HOW THE PICTURE MAPS
| In the picture | In the work |
|---|---|
| A recipe for a kitchen robot | A Gherkin scenario |
| Heat the pan | Given: the starting state |
| Add two eggs | When: the action |
| The eggs are set after three minutes | Then: the result you can check |
| The robot knows how to heat a pan | A step definition behind each line |
WHERE THIS PICTURE STOPS
- A vague step can match code that checks little or nothing. A pass is only useful if the assertions test the intended outcome.
- A recipe is used to make food, but a scenario is used to check the product.
- A robot is built for the kitchen, whereas steps need code written for each app.
HOOK
Given the start, when I act, then I see.
REMEMBER IT THIS WAY
A contrast: two neighbours told apart by one test.
Given is the state we start in, When is what the user does, and Then is the result we can check. A Then like 'works as expected' checks nothing.
| In the trick | What it stands for |
|---|---|
| Given | The starting state |
| When | The action |
| Then | The result you can check |
TELL A FRIEND
Gherkin structures examples in Given, When and Then. Step definitions and meaningful assertions make selected cases executable; text alone does not establish a check.
OFTEN MIXED UP WITH Specification by example. That topic explains why teams use key examples to specify a feature. This one writes those examples in a form a tool can run.
Sources & standards — 2 sources
- Market practice
Gherkin reference (Cucumber documentation) ↗ — Cucumber · Official reference: Given, When, Then, And and But are valid step keywords; Rule and Scenario Outline structures. A focused example need not ban And.
Publisher page opened on 5 November 2026. Earlier search-only notes are superseded for the claims stated here. Wording is paraphrased; source-figure reuse is not assumed.
- Market practice
Certified Professional for Requirements Engineering (CPRE) Foundation Level syllabus, English, version 3.3.0 (International Requirements Engineering Board) ↗ — International Requirements Engineering Board (IREB) · CPRE Foundation Level syllabus3.3.0,1April2026, §§3.2,3.3,4.4 (3.2 Natural-Language-Based Work Products; 3.3 Template-Based Work Products; 4.4 Validation of Requirements).
Primary versioned PDF opened via normal web tool and downloaded/extracted on2026-11-06. Copyright authors and IREB e.V.; original educational paraphrase with attribution. No source artwork copied.
PRACTISE AND KEEP
Sources for this topic — 6 sources
- Market practice
Gherkin reference (Cucumber documentation) ↗ — Cucumber · Gherkin reference (Cucumber documentation): Gherkin uses a small set of keywords to give structure to executable specifications; each step starts with Given, When, Then, And or But and a tool runs the steps in order (search excerpt, page not opened)
Publisher page opened on 5 November 2026. Earlier search-only notes are superseded for the claims stated here. Wording is paraphrased; source-figure reuse is not assumed.
- Market practice
Example Mapping (Cucumber documentation) ↗ — Cucumber (SmartBear) · Example Mapping (Cucumber documentation): examples gathered in a talk can be written as scenarios (registry source; page not opened in this batch)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
ISTQB Certified Tester Acceptance Testing (CT-AcT) syllabus ↗ — International Software Testing Qualifications Board (ISTQB) · Mirror copy of the publisher PDF (ISTQB syllabus CT-AcT v1.0, 21 June 2019), version checked against the document's own front matter, read in full text: AcT-2.2.2 (K3) apply the Gherkin language to a user story to write acceptance tests
Text read in full from a mirror copy of the publisher PDF (ISTQB syllabus CT-AcT v1.0, 21 June 2019), version checked against the document's own front matter. The page at this URL was not opened. Licence terms were not read, so put it in your own words and do not quote it.
Specialist review 6 November 2026: Actual related substantive chapters 1–5 and Appendix text reviewed for Acceptance2019; not an assertion that every source figure was visually reviewed. Professional certification guidance, not binding legislation or a formal ISO standard. Inherited full-text descriptions are not a claim that this audit read every PDF page.
- Simplified educational illustration
Payments Signal editorial teaching models — Payments Signal
What this simplifies: Daily List and the people are invented. The sources are the tool maker documentation and a syllabus, and we read search excerpts only. The example uses a few keywords and leaves out tables, outlines and tags. Real projects add more.
Used wherever diagrams, scenarios, figures, or example values are didactic constructions rather than sourced facts; every such use carries a simplifications disclosure. All people, companies, banks, and list entries in examples are fictional.
- Market practice
BDD history ↗ — Cucumber · Behaviour-driven development (host moved from specification-by-example to the Gherkin lesson) (search excerpt, page not opened).
Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
Certified Professional for Requirements Engineering (CPRE) Foundation Level syllabus, English, version 3.3.0 (International Requirements Engineering Board) ↗ — International Requirements Engineering Board (IREB) · CPRE Foundation Level syllabus3.3.0,1April2026, §§3.2,3.3,4.4 (3.2 Natural-Language-Based Work Products; 3.3 Template-Based Work Products; 4.4 Validation of Requirements).
Primary versioned PDF opened via normal web tool and downloaded/extracted on2026-11-06. Copyright authors and IREB e.V.; original educational paraphrase with attribution. No source artwork copied.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.