Behavior Driven Development With Gherkin

BDD is a software development approach that allows a Tester or Business Analyst to create test cases in simple text language i.e., English. The simple language used in the scenarios helps even non-technical team members to understand what is going on in the project. This help and improves communication among Technical and Non-Technical Team, Managers and Stakeholders. Behavior Driven Development(BDD) framework is an extension of Test-Driven Development(TDD).


BDD is the collaboration between the Business team and technical team. Usually, there is huge gap between Business team and Technical team and BDD helps to bridge the gap. So using the BDD we can build a common understanding between the teams on the behavior of the application. BDD generates a common document that can be understood by all team members and stakeholders.


3 Phases of BDD

Discovery: Explore and discuss on how the system should behave and the outcome of this phase is Agreed behavior of the system.

Formulation: Create concrete examples that can be automated, and the outcome of this phase is documented examples(Acceptance Test).

Automation: Coding as per the documented examples to implement the agreed behavior of the system, create automation tests taking one example at a time to guide development. Outcome of this phase is Code implementation and automation tests.

We can understand the BDD overview and how it works in different phase by following diagram


Generally, for any new enhancement, Feature, or change User story is created.

  • The user story is discussed among the team.

  • Conversation and discussion on how the system should behave.

  • Examples are created, discussed, agreed, and approved.

  • Examples are documented in a way that can be developed and tested with automation.

  • Finally goes into the coding phase where the implementation is done based on the documentation.

What is Gherkin?

Gherkin is a domain specific language that enables the definition of business behavior without the need of implementation. Since Gherkin uses plain English language to define the test it is very easy for technical and non-technical team member to understand the test or behavior of the software.

Gherkin Steps

1. Given

2. When

3. Then


Now lets understand the use of each one of them below:

1. Given : ‘Given’ step is used to describe the initial information of the system. Usually it used to describe the prerequisites before the test execution starts.

2. When : ‘When’ is used to describe an event and an action. This can be a person or a user interacting with the software or the system.

3.Then : ‘Then’ keyword is used to describe an expected result or an outcome.

Gherkin Example

Scenario: Amazon browsing history page

Given: User is on the Amazon Homepage

When: User Clicks on 'Browsing History' tab

Then: The browsing history page should load




75 views0 comments

Recent Posts

See All

Anatomy of a REST Request

Any REST request includes four essential parts: HTTP method Endpoint Headers Body An HTTP method describes what is to be done with a resource. There are four basic methods also named CRUD operations: