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
6
votes
6 answers

How can I make specflow cope nicely with dates/times?

I wish to be able to write tests like this: Background: Given a user signs up for a 30 day account Scenario: access before expiry When they login in 29 days Then they will be let in Scenario: access after expiry When they login in 31 days …
Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
6
votes
2 answers

Cucumber : How to skip subsequent steps and exit out of the scenario without failing the step / scenario?

I have had my feature file in Cucumber and am using Given, When, Then syntax(Gherkin) to write my scenarios in it and have the corresponding steps in the Step Definition file. I have a scenario, where I am checking if a particular data set…
user5252179
  • 133
  • 3
  • 20
6
votes
1 answer

Is there any After keyword is available like Background for running cucumber steps

I know Background keyword is available for running a common steps before running each scenario. Likewise is there anything like "After" keyword is available for the commons steps after each scenario, not the logical steps in java code like after…
mmar
  • 1,840
  • 6
  • 28
  • 41
6
votes
3 answers

Cucumber ordering of Given, When, Then (Given, When, Then, When, Then)

As an End-to-end Automation Tester I have always assumed that Given, When, Then statements (incorporated in the Gherkin Language when using Cucumber) should only ever appear in the order of 1. Given, 2. When, 3. Then. i.e. A test should not follow,…
Charlie S
  • 4,366
  • 6
  • 59
  • 97
6
votes
4 answers

No Colours in Specflow Feature Files on Visual Studio

I have the latest version of SpecFlow installed, and still the feature files display uncoloured, like so... (Not enough rep to insert images) Specflow uncoloured feature files Is there certain configurations that are set for colours to be displayed…
Taran
  • 491
  • 2
  • 8
  • 22
6
votes
2 answers

Are Cucumber and Gherkin alternatives to Mocha and Chai? Can Mocha and Chai be used with Java code?

If someone can point out any other source on StackOverflow etc. where more info about this exists, even that will be helpful.
user3251882
  • 922
  • 1
  • 11
  • 21
6
votes
1 answer

How to use whitespaces in feature names in Cucumber

I am using Windows and trying to run an existing feature pack which was initially built on Mac OS which allows them to get around the issue with using " \ " with the whitespace. I am using Ruby 2.2.3 and Cucumber. The feature names contain white…
jimmyr91
  • 73
  • 7
6
votes
3 answers

Array placeholder in Gherkin syntax

Hi I am trying to write express a set of requirements in gherkin syntax, but it requires a good deal of repetition. I saw here that I can use placeholders which would be perfect for my task, however some of the data in my Given and in my then are…
Obi
  • 3,091
  • 4
  • 34
  • 56
6
votes
2 answers

Gherkin - how do you write an unambiguous test case in English?

English could be ambiguous, and it seems to me there is an assumption in methodologies that employ Gherkin, that a anyone who speaks English to some degree, can write and understand the test cases, even before any code has been written. So how does…
inor
  • 2,781
  • 2
  • 32
  • 42
6
votes
2 answers

Specflow: Specifying multiple scenarios per feature

Going through SpecFlow docs, I'm trying to figure out if my perception is wrong. I would like to specify several completely different scenarios per feature. For example: Feature: Serve coffee Coffee should not be served until paid for …
Nir
  • 3,963
  • 8
  • 37
  • 51
6
votes
3 answers

continue running cucumber steps after a failure

Is there any way to continue executing Cucumber Steps even when one of the steps fails. In my current setup when a step fails , cucumber skips remaining steps....I wonder if there is some way to twick cucumber runner setup.. I could comment out…
Manish
  • 191
  • 2
  • 4
  • 12
6
votes
4 answers

Avoiding repeating yourself in Gherkin

So I've been using specflow for a while now and something has been bugging me. This is an example of a scenario we are currently using: Scenario: Select a region via selection button When I select "Scotland" from Available Regions And I…
Mark Broadhurst
  • 2,675
  • 23
  • 45
5
votes
1 answer

When writing a BDD feature, should I put previous user interaction into a Given step, or a When step?

I am trying to write requirements for a multi-step business process (via a wizard). I have many scenarios where user interactions with one screen will change whether you are allowed to pick options on another screen. For example (I've obscured the…
Merlyn Morgan-Graham
  • 58,163
  • 16
  • 128
  • 183
5
votes
3 answers

Cucumber Features and Step Definitions

I am new to Cucumber testing. I have created two features files: events.feature partner.feature and have my step definitions in a step_definitions folder: ./step_definitions/ events.rb partner.rb It seems that Cucumber looks in all the…
JonB
  • 1,320
  • 2
  • 15
  • 30
5
votes
4 answers

Dealing with multiple, slight variations in SpecFlow

Hi all We are developing a web service that will be available through SOAP and REST (xml and JSon). Our specflow features are mostly the same, i.e: Scenario: There are at least 3 radio Channels Given The test server is up and running And The…
Pedro G. Dias
  • 3,162
  • 1
  • 18
  • 30