• Sindhuja Hari

So, what is BDD?

Behavior Driven Development or popularly known as BDD, is a widely used development approach in the software industry as it empowers its user to write cases in plain English language. This helps team members even with no technical know-how to understand what is going on in the project that closes the gap between businesspeople and technical people

In addition to a low technicality and easier to understand approach, the main advantage of BDD is that it transpires from TDD ie. Test-Driven Development, which supports automated testing with multiple test data with minimum intervention in code.


BDD (Behavior Driven Development) Framework


BDD framework i.e., Behavior Driven Development is a software development approach that allows the tester/business analyst to create test cases in simple text language (English).

BDD transpires from the TDD i.e., Test Driven Development which allows the users to work with multiple test data with minimum intervention in the software code and thereby helps to increase the reusability of the code, which is a time-saving mechanism in software development/ test automation.

Before the BDD framework, everyone was using 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.


What is Gherkin Language?


Gherkin is a business readable language which helps you to describe business behavior without going into details of implementation. It is a domain specific language for defining tests in Cucumber format for specifications. It uses plain language to describe use cases and allows users to remove logic details from behavior tests.


Given – When – Then Approach


Given: Some given context (Preconditions).

When: Some Action is performed (Actions)

Then: Outcome/consequence after the above step


Cucumber reads Gherkin document and executes a test to validate that the software behaves as per the Gherkin syntax.


Important Terms used in Gherkin


  • Scenario

  • Given

  • When

  • Then

The naming convention is used for feature name. However, there is no set rules in Cucumber about names.



Important Terms used in Gherkin


Scenario


Scenario makes the core of Gherkin structure. It describes the functionality that is under test. Main aim of a scenario is to be able to make the viewer understand what is being tested and how. The scenario keyword is followed by an optional title


Given:


The use of Given keyword is to put the system in a familiar state before the user starts interacting with the system. However, you can omit writing user interactions in Given steps if Given in the "Precondition" step.


When:


When the step is to define action performed by the user.


Then:


The use of 'then' keyword is to see the outcome after the action in when step.


Gherkin Examples


Example 1:


Feature: Login functionality of social networking site Facebook.

Given: I am a Facebook user.

When: I enter username as username.

And I enter the password as the password

Then I should be redirected to the home page of Facebook


Example 2:


Given The login page is opening

When I input username, password and click the Login button

Then I am on the Homepage


Best practices of using Gherkin


  • Each scenario should execute separately

  • Every feature should be able to be executed along

  • Step’s information should be shown independently

  • Connect your Scenario's with your requirements

  • Create modular and easy to understand steps


Advantages of Gherkin


  • Gherkin is simple enough for non-programmers to understand

  • Programmers can use it as a very solid base to start their tests

  • It makes User Stories easier to digest

  • Gherkin script can easily understand by business executives and developers

  • Gherkin Testing targets the business requirements

14 views0 comments

Recent Posts

See All

Deploying Spring Boot applications on Heroku

Heroku: Heroku is a container-based cloud Platform as a Service (PaaS). Developers use Heroku to deploy, manage, and scale modern apps. It supports several programming languages and has a very simple