TOPIC 32/4413 MINNOT STARTED

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.

  1. Name the scenario
  2. Write the Given
  3. Write the When
  4. Write the Then
  5. Connect each line to code
One executable example

HOW THE PICTURE MAPS

How each part of the picture matches the work
In the pictureIn the work
A recipe for a kitchen robotA Gherkin scenario
Heat the panGiven: the starting state
Add two eggsWhen: the action
The eggs are set after three minutesThen: the result you can check
The robot knows how to heat a panA 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.

What each part of the trick stands for
In the trickWhat it stands for
GivenThe starting state
WhenThe action
ThenThe 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
  1. 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.

    Official reference: Given, When, Then, And and But are valid step keywords; Rule and Scenario Outline structures. A focused example need not ban And. · Checked 2026-11-05

    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.

  2. 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).

    CPRE Foundation Level syllabus3.3.0,1April2026, §§3.7 and4.1–4.4: prototype purposes, sources, technique families, quality needs/constraints, conflict methods and validation. · Checked 2026-11-06

    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
  1. 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)

    Official reference: Given, When, Then, And and But are valid step keywords; Rule and Scenario Outline structures. A focused example need not ban And. · Checked 2026-11-05

    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.

  2. 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)

    Per the search excerpt, example mapping uses four card colours for the story, the rules, the examples and the questions, and takes about a short session per story. Practitioner guidance, not a standard. · Checked 2026-10-18

    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.

  3. 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

    Version 1.0 syllabus (21 June 2019), read in full text. Used for the objective ids and levels, the modelling objectives in chapter 3, the four pillars of user experience requirements analysis in section 4.2.1 and the scope that leaves out operational acceptance testing. Paraphrased, not quoted. · Checked 2026-10-18

    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.

  4. Simplified educational illustration

    Payments Signal editorial teaching models — Payments Signal

    This site's own simplified teaching models. · Checked 2026-07-12

    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.

  5. Market practice

    BDD history ↗ — Cucumber · Behaviour-driven development (host moved from specification-by-example to the Gherkin lesson) (search excerpt, page not opened).

    Daniel (Dan) Terhorst-North pioneered behaviour-driven development; Given-When-Then and Gherkin. · Checked 2026-10-19

    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.

  6. 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).

    CPRE Foundation Level syllabus3.3.0,1April2026, §§3.7 and4.1–4.4: prototype purposes, sources, technique families, quality needs/constraints, conflict methods and validation. · Checked 2026-11-06

    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.