Gherkin files use the feature file extension. They’re saved as plain text, meaning they can be read and edited with simple tools. In this respect, Gherkin is very similar to file formats like Markdown, Textile, and YAML.
A Gherkin file is given its structure and meaning using a set of special keywords. There’s an equivalent set of these keywords in each of the supported spoken languages, but for now let’s take a look at the English ones:
Feature
Background
Scenario
Given
When
Then
And
But
*
Scenario Outline
Examples
We’ll spend the rest of this chapter exploring how to use the most common of these keywords, which will be enough to get you started writing your own Cucumber features. We’ll come back to look at the remaining keywords later in Chapter 5, Expressive Scenarios.
All of the examples in this chapter are valid Gherkin and can be parsed by Cucumber. If you want to play around with them as we go through the chapter, just create a features/test.feature working file. Then run it with the following:
| $ cucumber features/test.feature --dry-run |
The --dry-run switch tells Cucumber to parse the file without executing it. It will tell you if your Gherkin isn’t valid.
18.220.187.223