-
-
Notifications
You must be signed in to change notification settings - Fork 37
Cucumber Syntax
The following is a list of supported Cucumber syntactical elements with an example Cucumber Feature file. The Cucumber syntax is defined in a Xtext DSL file. The following is an example of a valid Cucumber file:
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
@release1
Scenario Outline: Add two numbers
Given I have entered <input_1> into the calculator
And I have entered <input_2> into the calculator
When I press <button>
Then the result should be <output> on the screen
Examples: sample data
| input_1 | input_2 | button | output |
| 20 | 30 | add | 50 |
| 2 | 5 | add | 7 |
| 0 | 40 | add | 40 |
@release1 @regression
Scenario: Regular numbers
Given I have entered 3 into the calculator
And I have entered 2 into the calculator
And I press divide
Then the result should be 1.5 on the screen
Feature (read more)
A feature can optionally have Tag
s, is defined by a mandatory Feature: string followed by a title
, can have a multiline description
, an optional Background
and one or more Scenario
or Scenario Outline
.
Background (read more)
A background is defined by a mandatory Background: string followed by a title
and can have a multiline description
.
Scenario (read more)
A scenario is defined by optional Tag
s, a mandatory Scenario: string followed by a title
, an optional multiline description
and one or more Step
s.
Scenario outlines (read more)
A scenario outline is defined by an optional Tag
s, a mandatory Scenario Outline: string followed by a title
, , an optional multiline description
, one or more Step
s and one or more Example
s.
Step (read more)
A step is defined by a mandatory Given, When, Then, And or But string followed by a step definition
and can optionally have an associated Table
Example (read more)
An example is defined by a mandatory Examples: string followed by a multiline description
and an optional sequence of Table
s.
Table (read more)
A table is defined by a sequence of rows where each cell row is delimited by a pipe |
char, like
| input_1 | input_2 | button | output |
| 20 | 30 | add | 50 |
| 2 | 5 | add | 7 |
| 0 | 40 | add | 40 |
Tag (read more)
Tags can be used before Feature
s, Scenario
s or Scenario outline
s and are defined by the at @
char followed by a string: Multiple tags can be space or line separated.
Each line starting with the hash #
char will be considered a comment and will be ignored by the parser.