BDD – Behavioral Driven Development

As it is discussed in the behavioral Driven Development introduction, the approach is test development mainly depends on the behavior of the application. This means it is developed after the functionality or the behavior of the application is implements. Testers or PS can write the test simple using text language (English)

This simple text language helps and improves communication among technical and non-technical teams, managers, and stakeholders. The implementation of BDD approach is so simple having the following advantages

  • Test scenarios are written separately in a different file, named as Feature file.
  • Tests are written by focusing user stories and system behavior in a layman/Gherkins language
  • Code is subject to be written differently in step definitions file i.e. Java, Python.

Why BDD?

BDD transpires from the TDD. TDD works fine in software development, provided the stakeholders are familiar with the framework being used and their technical knowledge is sufficient. However, this may not be the case always.

BDD provides a path that acts as a bridge to overcome the gap between the technical and the non-technical teams because the test cases are commonly written in simple text, i.e. English.   The main advantage of BDD is the low in complexity and clearer approach which is easier to understand.

How To Implement BDD?

Test scenarios should be written in plain language with a detailed description of the test. This will let us to know to test the application and the application behavior which can be understandable by all.

Figure 1.1 : – The BDD implementation

In the following line we will look the tool for implementing a BDD – which cucumber framework and a language that is used to write down the test case – Gherkin

Cucumber – BDD Framework Tool

Cucumber is a BDD implementation framework that is used to write a test case. the test case are written with a keyword Given, When And which address the Preconditions, Action and Expected outcome. Cucumber is a language-independent plugin as it is compatible with many programming languages E.g. JavaPython, etc. It supports a language Gherkins The implementation is as follow

Given A given context
When A user is performing an action
Then A particular outcome will be displayed.

Feature File

This is a feature that all the scenarios, pre-conditions and test cases are written down referring the feature that we are testing on. The feature is structured containing the Feature Title, Scenario and Test Steps in the form Given, When And, Then

Example : – The following example demonstrate how the Gherkin language is used to address the behavior of a test scenario

Feature: Users

Senario: SingUp
Given The user is already in Signup Page
And The user set userName and Password to register
When The user click on 'SignUp' button
Then The user successfully register
Feature: Users

Senario: SingIn
Given The user already registered
And The user provide correct userName and Password 
When The user click on 'logIn' button
Then The user successfully logged in to the home page

Setting Up BDD

To set up a BDD Test automation development, it is required to have the IDE, as well libraries. The details of the libraries are as follow

  • Java
  • Selenium
  • Cucumber

Advantage of BDD

  •  Easy concept of text in the form of feature file. this will allow stakeholders to write scenarios in Gherkin language from the user stories.
  • Easy language of cucumber scenarios helps them to understand the functionality in a better way.
  • Easier to have a reusability
  • Parameterizing Steps to better implement the test steps for different scearios
  • Continuous Integration – AzureDevOps, Jenkins

Worth Reading

Scroll to Top