top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-

BDD with Gherkin

Behavior Driven Development (BDD) is an approach that consists on defining the behavior of a feature through examples in plain text. These examples are defined before the development starts and are used as acceptance criteria


Gherkin is a format for Cucumber Specifications. It is a business readable language created for behavior descriptions.

The Main keywords in Gherkin are

· Feature

· Scenario

· Given

· When

· Then

A feature is a desired product functionality often involving multiple behaviors. In simple terms, Feature is collection of related scenarios.

Syntax for feature is:

Feature: Summary

A Scenario describes the steps and expected outcome for a particular test case.

Syntax for Scenario is:

Scenario: Title

Given steps are used to describe the initial context of the system - the scene of the scenario. It is typically something that happened in the past.

Syntax for Given is:

Given: Set up initial state

When steps are used to describe an event, or an action. This can be a person interacting with the system, or it can be an event triggered by another system.

Syntax for When is:

When: Perform Action

Then steps are used to describe an expected outcome, or result.

Syntax for Then is:

Then: Check end state





Simple example to understand Gherkin format

Given the login page is opening

When I input username, password and click on login button

Then I am on the homepage

Gherkin Examples:

Feature: Login functionality of social networking site

Scenario: Login to Facebook

Given: I am a Facebook user

When: I enter username as username and I enter password as the password

Then: I should be redirected to the Facebook homepage




Feature : Login functionality of Gmail


Scenario: TC01 - Successful Login to web Gmail

Given : I am on Login page

And: I am a registered user

When: I enter correct username and password

And: I click on Sign in button

Then: Inbox is displayed


Scenario : TC02 - Successful Login to web Gmail using sign in link in create account page

Given : I am on Create Google account page

And: I am a registered user

When: I click on Sign in instead link on Create Google Account page

Then: Login page is displayed

When: I enter correct username and password

And: I click on Sign in button

Then: Inbox is displayed


Scenario: TC03 - Successful Login to web Gmail

Given : Launch the browser

And: I am a registered user

And: I have multiple gmail account

When: Enter gmail.com

Then: List of all accounts are displayed

When: I select the account to login

Then: Password page is displayed

When: I enter the password

And: Click on Sign in button

Then: Inbox is displayed





Scenario :TC04- Successful Login to Gmail app

Given : I installed gmail app

And: I am a registered user

When: I launch the gmail app

And: I enter the correct user name and password

And: I click on Sign in button

Then: Inbox is displayed


Scenario :TC05- Automatic successful Login to web Gmail

Given : I have already logged in to the gmail account

And: I am a registered user

When: I launch gmail website

Then: Inbox is displayed


Scenario :TC06 -Automatic successful Login to web Gmail

Given : I have already installed and logged into gmail app

And: I am a registered user

When: I launch the gmail app

Then: Inbox is displayed


Scenario :TC07--Unsuccessful Login to web Gmail

Given : I am on Login page

And: I am a registered user

When: I enter incorrect username and password

And: I click on Sign in button

Then: Inbox is displayed


Scenario : TC08-Unsuccessful Login to Gmail app

Given : I installed gmail app

And: I am a registered user

When: I launch the gmail app

And: I enter incorrect user name and password

And: I click on Sign in button

Then: Inbox is displayed


Scenario:TC09- Forgot my password functionality

Given: I am on login page

And: I am a registered user

When: Click on more ways to sign in option

And: Click on Forgot password link

And: Enter the incorrect last password

And: Click on Sign in button

Then Autorecovery page is displayed

And Notification is received on phone

When: Click on Yes in the notification

Then: Enter the new password and confirmation password

And: click update button

Then: Inbox is displayed



Scenario : TC10-Successful Gmail account creation on web

Given : I click on Home page

When: I click on create an account button

Then: Create your Google Account page is displayed

When: I enter firstname, last name, username, password, confirm password information

And: Click on Next

Then: Inbox page is displayed



Scenario :TC11- Successful Gmail account creation on app

Given : Gmail app is installed

When: I click on create an account button

Then: Create your Google Account page is displayed

When: I enter firstname, last name, username, password, confirm password information

And: Click on Next

Then: Inbox page is displayed


Scenario:TC12 - Duplicate Email

Given : I am on Create Google account page

When: I enter existing email id for creating account

Then: Email id is already registered message is displayed


Feature : Unlocking my phone


Scenario : TC01- Unlock my phone using thumb impression(Succesfully)

Given: Registered thumb impression

when : Press power button

then: Screen displays thumb impression option

when : Thumb impression is provided

then : phone is unlocked


Scenario :TC02- Unlock my phone using thumb impression(Un Succesfull)

Given: Registered thumb impression

when : Press power button

then: Screen displays thumb impression option

when : Wrong thumb impression provided

then : please try again


Scenario :TC03- Lock the phone with multiple incorrect thumb impression after 3 attempts

Given: Registered thumb impression

when : Press power button

then: Screen displays thumb impression option

when : Wrong Thumb impression is provided

then : please try again

when : Wrong thumb impression is provided

then : please try again

when : Wrong thumb impression is provided

then : phone is locked. please try again after 30 seconds


Scenario :TC04 Unlock the phone using password(Successfully)

Given : Registered Password

When : Press power button

then: Screen displays enter password option

when :Password is entered

then : Then phone gets unlocked


Scenario :TC05- Unlock the phone using password(Unsuccessful)

Given : Registered Password

When : Press power button

then: Screen displays enter password option

when :Password is entered

then : Wrong Password. Please try again


Feature: Calculator


Scenario: TC01 - Sum of two numbers

Given: First number is 20 and second number is 10

When: Addition operation is performed

Then: Result of two numbers is displayed


Scenario: TC02 - Subtraction of two numbers

Given: First number is 20 and second number is 10

When: Subtraction operation is performed

Then: Result of two numbers is displayed


Scenario: TC03 - Multiplication of two numbers

Given: First number is 20 and second number is 10

When: Multiplication operation is performed

Then: Result of two numbers is displayed


Scenario: TC04 - Division of two numbers

Given: First number is 20 and second number is 10

When: Division operation is performed

Then: Result of two numbers is displayed


Scenario: TC05 - Comparing two numbers

Given: First number is 20 and second number is 10

When: first number is greater than second

Then: First number is greater message is displayed



Scenario: TC06 - Comparing two numbers

Given: First number is 20 and second number is 10

When: first number is less than second

Then: Second number is greater message is displayed


Scenario: TC07 - Average of two numbers

Given: First number is 20 and second number is 10

When: first number is added to second and divided by 2

Then: Average of numbers is displayed


Scenario: TC07- Square of a number

Given: Number is 20

When : Number multiplied by number

Then: Multiplied number is displayed










599 views0 comments

Recent Posts

See All
bottom of page