Skip to main content

Gherkin Language Keywords

Gherkin has its own set of keywords, and each keyword has some meaning. To learn how to write steps in the Gherkin language, you must be familiar with its keyword. 

If you are using any editor, these keywords are highlighted with some color. Each keyword is translated into many spoken languages; we’ll use English in this article.

Categories of Gherkin Keywords

We can divide Gherkin Keywords into two categories:

  1. Primary Keywords: Feature, Rule, Scenario, Example, Given, When, Then, And, But, Background, Scenario Outline, Examples
  2. Secondary Keyword: Doc String("""), Data Tables(I), @(Tags), #(Comment) 

Each step starts with Given, When, Then, And, or But.

List of Gherkin Primary Keywords and their synonyms

You can replace each Keyword with its Synonyms in your Gherkin File.

Keyword Synonyms Description
Feature Business Need, Ability Feature provides a high level description of a software feature. It is used to group related scenarios.
Background   Runs steps before Scenario
Scenario Example Starts a new scenario
Scenario Outline Scenario Template Starts a new scenario with multiple examples
Given *, And, But Puts the system in a predefined state or specify your pre conditions in it
When *, And, But Use when, to describe an event or action
Then *, And, But Use Then, to describe an expected outcome or result
Examples Scenarios List examples for Scenario Outline
Rule   Represent one business rule that should be implemented. It grouped together several scenarios that belongs to same rule.

Note: And is used for statements that are an addition to the previous steps and represent positive statements. But are used for statements that are an addition to the previous step and represent negative statements.

This is an overview of Gherkin Keywords; we will discuss each keyword in detail with examples while working on our BDD tools like Cucumber, Behat, etc.

Gherkin Keywords List

Submitted by tgoswami on December 21, 2016

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.