Gherkin turns shared understanding of desired behavior into business-readable specifications. Its simple, structured syntax can also be processed by automation tools; using it for test scripts alone does not mean a team is practicing behavior-driven development. section 6.6 section 8.2
A feature file is plain text, usually ending in .feature, organized with a small set of keywords:
- Feature names the feature; Rule groups scenarios that illustrate a business rule; Scenario introduces an example. section 6.3
- Given, When, and Then introduce scenario steps. And joins steps; automation frameworks can use step text to identify code to run. section 6.3
Listing 6.1 Sample feature file (with only one scenario fully fleshed out)
Feature: Change delivery address
Rule: Allow address change if not picked up yet
Scenario: Order waiting for pickup
Given the customer has placed an order
And the order is waiting for pickup
When they request to change the delivery address
Then the address change should be allowed
Scenario: Request to change address received after order collection
Given …
When …
Then …
Scenario: Order picked up during address change process
Given …
When …
Then …
Rule: New address should be in range
Scenario: New address is in range
Given …
When …
Then …
Scenario: New address is out of range
Given …
When …
Then …
The delivery-address feature shows how rules group examples, including whether an order can be changed before pickup and whether a new address is in range. section 6.3
Use business language that stakeholders and delivery teams can understand. Gherkin is tool-independent, supports multiple spoken languages, and is compatible with scenario automation tools. Automatically checked specifications can serve as living documentation, alerting teams when documented behavior and implementation diverge. section 6.6 section 6.3
For legacy systems, avoid copying manual test scripts directly into Gherkin. Assess which scenarios will provide valuable documentation, especially around functionality likely to change. section 11.4

