Technology

Gherkins as BDD language

Gherkin is a plain-text language with a simple structure. It is designed to be easy to learn by non-programmers, yet structured enough to allow concise description of test scenarios and examples to illustrate business…

Share this article
FacebookLinkedInX

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

Here is a sample Gherkin document:

Gherkin - Syntax

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

    Examples:                

InputExpected Output

balance = ₹100

card is valid

Atm has sufficient money > ₹20

ATM should dispense ₹20

Balance = ₹80

Card should be returned


It makes it easy for a team of technical and non-technical members to understand the requirement without confusion.

As a developer, you can now work on technically designing it into modules / classes, methods and properties.

This Feature Test Document (FTD) can be the output of a discussion with the client / market research team who provide requirements through examples.

Benefits:

  1. It is more clear than a requirement specification document in terms of expected inputs and outputs.
  2. This is a technical document which when given to a system can execute them as testcases.
  3. This document can be easily translated into an assertion language test case by a Unit-test developer
  4. It can be easily interpreted by Development, Testing, UI, Management team without any confusions

Originally published on Inspire Innovative Learning.

View the original article
Start a discussion