QA Revolution

What is Gherkin Framework for Behavior Driven Development?

using Gherkin framework for BDDBehavior Driven Development has gained a lot of traction over the past several years with the adoption of Agile across most IT organizations.  One of the most common used tools is Cucumber and it uses the Gherkin framework to automate tests.  Gherkin language is defined as a business readable, domain specific language created especially for behavior descriptions.  The purpose of Gherkin is to promote behavior driven development across the entire team.  This includes business analysts, developers, testers, and product owners.  The Gherkin framework promotes firmly written requirements and eliminate ambiguity.  While Gherkin is primarily used in English, there are a total of 37 spoken languages that can be used.  Gherkin serves two basic purposes: provides project documentation and helps in creating automated tests.  The most commonly used automation tool for Behavior Driven Development is Cucumber.

Gherkin Language Keywords

Here are the primary Gherkin keywords:

  • Feature
  • Rule
  • Example or Scenario
  • Given, When, Then, And, But
  • Background
  • Scenario Outline or Scenario Template
  • Examples

Here are secondary Gherkin keywords:

  • Document Strings: ” “
  • Data Tables: |
  • Tags: @
  • Comments: #

Gherkin Syntax Example

#This is an example of how you can use the Gherkin syntax

Feature: Login functionality of Amazon

Given: I am an Amazon user

When: I enter username as username.

And I enter the password as password

Then I should be redirected to the home page of Amazon

Gherkin Best Practices

  • Each feature should be executed separately
  • Each scenario should be executed separately
  • Leverage your scenarios with your requirements
  • Make your steps modular and simple to understand
  • Combine common scenarios

Gherkin Advantages

  • Gherkin syntax is easy and simple for everyone including non-programmers to understand
  • Programmers can leverage Gherkin to write automated tests
  • Requirements are firm and unambiguous
  • Gherkin can be used to write user stories
  • You don’t need to be an expert to understand Gherkin
  • Gherkin automatically links acceptance tests to automated tests
  • There is significant reuse of tests

Gherkin Disadvantages