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
11
votes
2 answers

Specflow use parameters in a table with a Scenario Context

I am using Specflow in C# to build automatic client side browser testing with Selenium. The goal of these tests is to simulate the business scenario where a client enters our website in specific pages, and then he is directed to the right page. I…
Wasafa1
  • 785
  • 2
  • 10
  • 21
10
votes
3 answers

How to pass variable in feature background "Given" statement in cucumber?

@TestHomeValidation Feature:copy function test Background: Given I am running test in "VARIABLE" environment Can I use VARIABLE in above background given statement? I want to pass this VARIABLE value from properties file.
Manoj Mali
  • 111
  • 1
  • 1
  • 6
10
votes
1 answer

Updating the name of SpecFlow scenario outline variations

I have this feature file: Scenario Outline: Example Given I am a user When I enter as an amount Then the result should be Examples: | x | result | | 3 | 3 | | 1 | 1 | My issue is that…
CaffGeek
  • 21,856
  • 17
  • 100
  • 184
10
votes
4 answers

How do I create a Cucumber DataTable?

I want to manually set up a Cucumber DataTable using Java (instead of Gherkin). In Gherkin, my table would look like this: | h1 | h2 | | v1 | v2 | My Java so far looks like this: List raw = Arrays.asList( "v1", "v2"); DataTable dataTable =…
Christian
  • 6,070
  • 11
  • 53
  • 103
10
votes
1 answer

Multi dimensional Scenario Outlines in Specflow

I'm creating a Scenario Outline similar to the following one (it is a simplified version but gives a good indication of my problem): Given I have a valid operator such as 'MyOperatorName' When I provide a valid phone number for the operator …
g.cacciapaglia
  • 259
  • 3
  • 9
10
votes
3 answers

How do I resolve a Cucumber 'can't load such file' warning?

I'm trying to work through 'The Cucumber Book', but Cucumber is not behaving as expected. I'm on Windows 7 (32-bit), and I'm reasonably confident I have Ruby and the necessary gems installed properly. However, when I run cucumber I get the following…
dglass
  • 103
  • 1
  • 5
10
votes
1 answer

Example of a scenario written in Gherkin Pirate

From what I can see, Gherkin supports many different languages including Pirate Could someone list an example of the keywords in pirate and what a scenario may sound like or know of a site that has some example listed?
Mark Pearl
  • 7,573
  • 10
  • 47
  • 57
9
votes
1 answer

Using SpecFlow for End-to-End Regression Testing

We are employing BDD and using SpecFlow to drive our development (ATDD). Our QA team would like to define their own 'end-to-end regression tests (in Gherkin/SpecFlow) and re-use the Steps we have already defined. (Please note - I know that this is…
Mark Chidlow
  • 1,432
  • 2
  • 24
  • 43
9
votes
1 answer

SpecFlow -- Step (Given) with the same regex in different classes not executing independently

I have two classes (class A and B) both marked with [Binding]. Currently I'm using a class per feature. Classes A and B both have a step that looks like this: [Given(@"an employee (.*) (.*) is a (.*) at (.*)")] public void…
SideFX
  • 839
  • 1
  • 12
  • 34
9
votes
1 answer

Gherkin + Behat Scenario outline throws Behat\Gherkin\Exception\ParserException

I am trying to run registration example and I am getting stuck Scenario: New user registration; poor password Given I am on "/register" When I fill in "username" with "admin" And I fill in "password1" with "" And I fill in "password2"…
Fatmuemoo
  • 2,187
  • 3
  • 17
  • 34
9
votes
3 answers

BDD, SpecFlow and Gherkin all together

I have heard of BDD (Behavior Driven Development) just recently, and I liked the idea. since I work mainly with C# and .NET, I found SpecFlow, then learned that SpecFlow uses Gherkin and now I feel lost. Where do you find official documentation that…
Ibrahim Najjar
  • 19,178
  • 4
  • 69
  • 95
9
votes
1 answer

Equivalent of Background to run after scenarios

I'm new to SpecFlow, and am setting up a number of test features/scenarios that are for authenticated users of different role types. I'm doing this via browser automation with Coypu. So I have a Background step in the feature to set up the log in…
ngm
  • 7,277
  • 1
  • 53
  • 62
8
votes
2 answers

Cucumber: When to use tags/hooks vs backgrounds

I was wondering if there is a good argument for or against using backgrounds in cucumber when compared to using tags and hooks. Having a logged in user before the start of a test could go either like this: Background: Given that I am logged…
Marc Seeger
  • 2,717
  • 4
  • 28
  • 32
8
votes
1 answer

What person and mood should I use in Gherkin/Specflow Given/When/Then statements?

I am a bit confused with the way people write statements in the Gherkin language to describe various actions performed for acceptance testing. In some articles people use "I" and in some articles people use "User". The same is the case for reaction…
Suraj Gupta
  • 390
  • 1
  • 9
  • 25
8
votes
1 answer

Specflow Given When Then BUT?

I have been using SpecFlow for a while, without making use of the "but" logic. Considering the following scenario: Scenario: Kiran logs into the system but doesn't click remember me Given I have a username of 'Kiran' And a password of…
K-Dawg
  • 3,013
  • 2
  • 34
  • 52
1 2
3
77 78