Gherkin is a small, plain-language syntax for writing down how software should behave, as examples anyone on a team can read. Tools such as Cucumber can then run those examples as automatic tests. It is the format behind behaviour-driven development (BDD).

The keywords

  • Feature — names the thing being described, with a short sentence about why it matters.
  • Scenario — one concrete example of the behaviour, written as a short list of steps.
  • Given — the starting situation, before anything happens.
  • When — the action the user (or the test) takes.
  • Then — the outcome you expect to see afterwards.
  • And, But — continue the previous step without repeating its keyword.

An example

Feature: Search
  Scenario: Search and see results
    Given I am on https://google.com
    When I type "testing examples" in the search box and click submit
    Then I see search results

Each step is plain text that a test tool maps to a line of code. See the same scenario written as Selenium and Playwright code on the Given-When-Then examples page.