Questions tagged [gherkin]

Gherkin is the language used to write specifications for Cucumber, Specflow and similar BDD frameworks. It is a business-readable, domain-specific language that lets you describe your software’s behaviour without detailing how that behaviour is implemented.

Gherkin is the language used to write specifications for Cucumber, Specflow and similar BDD frameworks. It is a business-readable, domain-specific language that lets you describe your software’s behaviour without detailing how that behaviour is implemented.

Gherkin serves two purposes — documentation and automated tests. The third is a bonus feature — when it yells in red it’s talking to you, telling you what code you should write.

Gherkin’s grammar is defined in the Treetop grammar that is part of the Cucumber codebase. The grammar exists in different flavours for many spoken languages (37 at the time of writing), so that your team can use the keywords in your own language.

There are a few conventions:

  • A single Gherkin source file contains a description of a single feature.
  • Source files have the extension .feature.
  • There is a fundamental pattern to each Gherkin scenario, with a context: (Given), an event (When), and an outcome (Then).

Gherkin was invented by Alsak Hellesoy.

You can read more about Gherkin here: https://github.com/cucumber/gherkin/wiki

Documentation of Cucumber and Gherkin: https://www.cucumber.io/

.NET implementation: http://www.specflow.org/

Python implementation: https://behave.readthedocs.io/

1169 questions
94
votes
14 answers

How to do block comments in Gherkin?

In gherkin syntax (used by Cucumber and SpecFlow, I can comment out a line by prefixing it with '#' Is there any way to block-comment multiple lines?
dbruning
  • 5,042
  • 5
  • 34
  • 35
77
votes
5 answers

How do I disable a feature in specflow (Gherkin) without deleting the feature?

I have some SpecFlow features (using the Gherkin syntax) and I would like to temporarily disable the feature to prevent its tests from running? Is there an attribute I can mark the feature with to do this? I'm guessing that something that works with…
Simon Keep
  • 9,886
  • 9
  • 63
  • 78
56
votes
2 answers

Codeception, write acceptance tests with the pageObject design pattern and gherkin

I'm looking for a simple example of code with the pageObject design pattern and gherkin because when I follow the codeception BDD documentation, all examples written in the tests/support/AcceptanceTester.php. I don't understand (poor English skills…
spacecodeur
  • 2,206
  • 7
  • 35
  • 71
41
votes
1 answer

Can I escape the pipe in specflow (or gherkin)

I've got a specflow step table that I want to have the | (pipe) character as a part of the content. Example: Then the data should be | Field | Value | | SomeField | a|b|c | But this doesn't work. How can I escape the pipe character?
viggity
  • 15,039
  • 7
  • 88
  • 96
40
votes
2 answers

Is it possible to write a gherkin step on multiple lines?

I am new to the Gherkin language and this seems to me like very basic question but I could not find answer to it. I am aware that it is possible to write multi-line step argument in Gherking, like this: Given a blog post named "Random" with Markdown…
Dragan Nikolic
  • 1,536
  • 3
  • 17
  • 24
38
votes
8 answers

Are there any non-developer tools to edit gherkin files?

Gherkin syntax files are just plain text so any editor such as notepad can be used. However, one of the more important things we are using this for is to provide tables of sample data. Without good formatting options the files become hard to…
toddles2000
  • 1,032
  • 1
  • 8
  • 16
31
votes
2 answers

Parse issues when trying to use "Examples" section in Cucumber feature

No luck in googling on this error message features/manage_hand_evaluator.feature: Parse error at features/manage_hand_evaluator.feature:21. Found examples when expecting one of: comment, py_string, row, scenario, scenario_outline, step, tag.…
Craig Flannagan
  • 609
  • 2
  • 8
  • 16
29
votes
2 answers

Is it possible to navigate from feature file to step definition in VSCode

I am primarily using RubyMine for Cucumber/Ruby, and now, I'm getting my hands on VSCode, with which I'm able to run and debug test cases. I can't find a way to navigate from feature to step definition. I tried searching for extensions and…
Vignesh Paramasivam
  • 2,360
  • 5
  • 26
  • 57
29
votes
5 answers

Is Page Object Model linking compatible with Cucumber's Gherkin?

With Test Automation's Page Object Model we link pages together like this: WebDriver driver = new WebDriver() HomePage homePage = new HomePage(driver); LoginPage loginPage = homePage.GoToLoginPage(); WelcomePage welcomePage =…
Charlie S
  • 4,366
  • 6
  • 59
  • 97
29
votes
5 answers

Is it acceptable to write a "Given When Then When Then" test in Gherkin?

Is it acceptable to write a "Given When Then When Then" test in Gherkin? A real-life example is as follows all AllPlayers.com Scenario: Successfully register a user Given I am on homepage And I am not logged into an account When I follow…
General Redneck
  • 1,240
  • 2
  • 13
  • 28
28
votes
2 answers

Is it ok to have multiple groups of Given/When/Then in a single gherkin scenario

I'm writing acceptance tests in Gherkin where I want to test for multiple changes in the UI of a web app based on an initial action. Here's an example: Scenario: Cancel editing a new text asset Given the user…
Geoffrey Hing
  • 1,575
  • 2
  • 15
  • 22
25
votes
7 answers

How to learn/teach Gherkin for Cucumber

I'd like to enable the business analysts to be able to write all of their specs for features, scenarios and steps that is Cucumber friendly using Gherkin. I've read some of the basic info on the github site for Cucumber and from doing a quick Google…
Satchel
  • 16,414
  • 23
  • 106
  • 192
24
votes
4 answers

Should BDD scenarios include actual test data, or just describe it?

We've come to a point where we've realised that there are two options for specifying test data when defining a typical CRUD scenario: Option 1: Describe the data to use, and let the implementation define the data Scenario: Create a region Given…
James Morcom
  • 1,749
  • 14
  • 17
23
votes
5 answers

Pretty output of Gherkin feature files

We're building up a specification in Gherkin, and we'd like to present the feature files to the business stakeholders. How can we export all our feature files in some sort of 'pretty' format? For example: Generate a document containing all…
dgmstuart
  • 728
  • 2
  • 7
  • 17
20
votes
4 answers

Where can I find a Gherkin language spec/guide?

I'm trying to find out all available syntax/format in Gherkin, such as about multiline argument and everything else I don't know yet. After digging Google search results though, it seems that the comprehensive guide is located in here: I thought…
ryaner
  • 3,927
  • 4
  • 20
  • 23
1
2 3
77 78