Requirements & behavior · Scenario language

Gherkin

Express a concrete behavior through starting conditions, an event, and an observable outcome.

Introductory · 3 drills · Reviewed 2026-10-24

What it helps you do

Make an interpretation of a requirement concrete enough for people to discuss and, with implementation, exercise.

Starting knowledge: No specialist knowledge is required.

  • Use Given for relevant starting context.
  • Use When for the event under examination.
  • Use Then for an observable outcome; keep incidental interface details out unless they matter.

The problem it came from

Gherkin is the scenario language associated with the Cucumber behavior-driven development ecosystem. Its keywords structure examples for people and tooling.

Executable scenarios require step definitions connected to an implementation. A text file with Given, When, and Then is not automatically a working test.

Work through an example

STARTING POINT
The registration form works even if the user clicks twice.
APPLYING THE APPROACH
Scenario: Repeat an existing confirmed registration
  Given Maya has a confirmed place in workshop A
  When Maya submits the same registration again
  Then Maya receives the existing confirmation
  And no additional place is reserved
  • The initial state is explicit.
  • The outcome covers both the visible confirmation and the resource effect.
  • The scenario leaves identity matching to a separately defined rule.

Where it helps. Where it stops.

Use it when

  • Agreeing acceptance examples for a feature.
  • A prose rule has several plausible interpretations.

Potential benefits

  • Concrete cases expose differences between intended and assumed behavior.
  • A scenario can bridge product discussion and automated checks when the implementation is connected.

Limits and common mistakes

  • A passing example does not establish all possible cases.
  • Scenarios that only describe clicking buttons may hide the business outcome being tested.
Applying it with AI

The prompt below asks for this structure. It does not guarantee accuracy, complete coverage, better learning, or conformance to a standard. Treat those outcomes as separate checks.

Practise the judgment

Try a choice, inspect a boundary, then explain a case yourself. Hints and answers are available whenever you need them.

DRILL 01 Not attempted

Which Then statement best checks the duplicate-registration rule?

Choose one answer
Hint

What outcome matters if the interface changes?

Explained answer

Best answer for this case: Then no additional place is reserved

It checks the domain consequence rather than incidental presentation.

DRILL 02 Not attempted

A .feature file exists but has no step definitions. What can you claim?

Choose one answer
Hint

Textual specification and executed evidence differ.

Explained answer

Best answer for this case: The behavior has been written as a scenario

The scenario can support discussion, but execution requires implementation bindings and actual results.

DRILL 03 Not attempted

Write a failure scenario for a new registration without an email.

Hint

Consider both the message and the resource effect.

Explained answer & self-review rubric

Given no registration exists for this participant, when a registration is submitted without an email address, then the service requests an email and does not allocate a place.

  • Specify new-registration context
  • Name missing input
  • Check no place is consumed

Take it into your own work

Manual template

Use this structure yourself, with a colleague, or in your preferred writing tool.

Feature: [behavior]

Scenario: [concrete case]
  Given [relevant starting state]
  When [one event]
  Then [observable result]
  And [important consequence]

Open questions:
Implementation step definitions:

Review the result

  • Is the scenario a concrete example?
  • Are outcomes observable?
  • Are step definitions present before calling it an automated test?
Use this approach with your own AI tool
Help me apply Gherkin to the material below.
Reader and existing knowledge: [describe]
Task and desired outcome: [describe]
Use these principles: Use Given for relevant starting context.; Use When for the event under examination.; Use Then for an observable outcome; keep incidental interface details out unless they matter..
Preserve source facts, identifiers, quantities, conditions, exceptions, and uncertainty.
Separate supplied facts from assumptions. Ask for missing information instead of inventing it.
Explain your representation choices and provide a review checklist. Do not claim formal compliance or correctness from formatting alone.
Material: [paste only information you are permitted to share]
Download prompt

Go to the source

History and the underlying approach are grounded in these references. Examples, prompts, and practice cases here are original educational adaptations. Edition-specific details should be checked against the referenced publication.

Last editorial review: 2026-10-24. An overview is not certification, and this guide is not a reproduction of a standard.