Writing scenarios with Gherkin syntax

Hiptest enables you to create executable specifications written in a language called Gherkin.


Gherkin is plain-text language with a little extra structure. Gherkin is designed to be easy to learn by non-programmers, yet structured enough to allow concise description of examples to illustrate business rules in most real-world domains.

Here is a sample Gherkin document:

Feature: Account Holder withdraws cash

  Scenario: Account has sufficient funds
   Given the account balance is $100
     And the card is valid
     And the machine contains enough money  
    When the Account Holder requests $20
    Then the ATM should dispense $20
     And the account balance should be $80
     And the card should be returned

The main keywords In Gherkin are:

  • Feature
  • Scenario
  • Given, When, Then, And, But (Steps)
  • Background
  • Scenario outline
  • Examples

STEP 1: LET’S activate the Gherkin option

In your project settings panel, activate the Gherkin option.

BDD mode

This will enable you to write scenarios using the Gherkin syntax. The step editor in the scenario page will create only action words (reusable steps) and interpret the Gherkin keywords.

Step 2: create a feature

Your features are managed with folders to better organize your project.


A feature has a description that provides the context. It is usually written this way:

As a [role]
I want [feature]
So that [benefit]

A feature contains one or many scenarios that describe its behaviors.

Step 3: write a scenario with the Given/When/Then syntax

By getting the business users, the analysts, the testers and the developers to adopt this vocabulary of “given/when/then”, lots of ambiguities fall away and conversations become more efficient.

Let’s write our first step: given the account balance is “$100”

Voila_Capture 2015-09-02_03-05-38_PM

Hiptest interprets and highlights the keyword Given. It will also consider $100 as a parameter because of the double quotes “my parameter value“. This way you’ll be able to reuse the same step in the future with a different value.

First step

And after a couple of seconds we get the following scenario.

Full scenario

Note that the step editor comes along with a powerful suggestion capability that enables you to reuse existing steps and design scenarios with a consistent business terminology. It’s also possible to use free text parameters in steps.

Step 4: add examples and use scenario outline

Cloning scenarios to use different values can quickly become tedious and repetitive. Scenario outlines allow you to more concisely express these examples through the use of parameters and datatable. Using our previous scenario we can create 3 examples.


When you create a new step, you can directly use the column name between “…” to use it as a parameter:


After the step validation, you can notice that the character ‘=’ is automatically set before the column name. This indicates that the word after the ‘=’ character is a variable that will be replaced by the matching datatable column value.


You can also write an expression as a parameter value. This expression can use the data table column names. In this case, the expression should be surround by ${…}. For example, here, the parameter value is the addition of the value of the column x and the column y:


After clicking on “View tests”, you get a preview of your generated tests:


Now that we have the scenarios completed let’s execute them.