Glossary
Glossary Gherkin

Gherkin

Also known as: given-when-then, feature file, cucumber syntax
TestingBDD

Definition

A plain-language way of writing an example as a test: Given a situation, When something happens, Then the outcome — readable by the person who asked for the behavior and runnable by a tool like Cucumber

The structure is the point. A scenario has to name its precondition, its trigger and its observable result, which is the same discipline as a good bug report or acceptance criterion. The tool running it is secondary; a scenario nobody can read is a unit test with extra words.

Tech

Behavior-driven development's notation. Here the shape appears without the tool: the e2e specs are named for what a person does and sees, and a pull request's verification table is Given / When / Then in columns.

One feature file, as the review gate on this site would be written — a rule, a scenario for each side of it, and a table that runs the same scenario once per row:

review-gate.feature
Feature: The review gate
  A public page in a bucket collection is held as internal
  until the author vouches for it with a reviewed date.

  Background:
    Given a note with visibility "public"
    And the note is in a review-gated collection

  Rule: An unreviewed page is not a visitor's

    Scenario: A visitor cannot see an unreviewed public note
      Given the note has no reviewed date
      When a visitor opens the notes index
      Then the note is not listed
      And the note is not in the sitemap

    Scenario: A member can still read it at its URL
      Given the note has no reviewed date
      When a member opens the note's URL
      Then the note renders

  Scenario Outline: Adding the date is the review
    Given the note carries reviewed "<date>"
    When a visitor opens the notes index
    Then the note <outcome>

    Examples:
      | date       | outcome       |
      | 2026-09-21 | is listed     |
      |            | is not listed |

  @wip
  Scenario: Wilting a page pulls it back
    Given the note is reviewed
    And the note's status is "wilted"
    When a visitor opens the notes index
    Then the note is not listed

Every keyword in it — Feature, Background, Rule, Scenario, Scenario Outline, Examples, Given/When/Then/And, a @tag — is the whole language; the rest is the sentence a product owner would say. The <date> placeholders are filled from the table, so one scenario is two tests.

Related Terms

See Also

  • a: Appearance
  • ?: Keyboard shortcuts