Gherkin test syntax

This is a quick reference of the syntax for editing Gherkin tests. For a comprehensive description, see the Gherkin documentation.

Gherkin tests are defined using the following structure.

Tip: Click a keyword below to see its description, syntax, and an example.

Note: When editing, a red X is displayed next to any lines that are not syntactically or logically correct.

Basic example

Feature: Buying items in shopping cart, single user
 
	Background: 
		Given: payment security system is up
 
	Scenario: Julio buys items in his cart
		Given a customer named "Julio Brown" 
		Given I am logged in as Julio 
		Given I have at least one item in cart
		When I try to buy items in my cart
		Then I should be asked for my payment method 
 

Example with parameters

Feature: Buying items in shopping cart for many users
 
	Background: 
		Given: payment security system is up
 
	Scenario Outline: Many users buy items in their carts
		Given a customer named "<customer>" 
		Given I am logged in as "<customer>" 
		Given I have at least one item in cart
		When I try to buy items in my cart
		Then I confirm my payment method "<payment>"
 and proceed to checkout. 
 
		Examples:
		| customer | payment |
		| Jane Doe | Paypal |
		| Jorge Rodrigues | VISA |
		| Sally Dunn | VISA |
		| Pierre Bisset | American Express |
		| Masayoshi Horita | Cash |