Behavior Driven Development in Agile Projects

Abstract

Behavior Driven Development (BDD) has gained high attention & adoption in agile development projects in recent years. This article provides basic understanding of BDD & fundamental practices followed in Behavioral Driven Development projects.

Behavioral Driven Development is an Agile software development process which is based on Three Amigo concept i.e. Developer, QA & Business participants. The language used in writing BDD is the natural and simple language which enhances collaboration between technical and non-technical team.

BDD = Business Behavior + TDD (test driven development)

In Figure.3, we can see that different person perceives an elephant differently because everyone is in their own space.

Now consider elephant as a software requirement and if developer, tester and business analyst start staying in their own worlds, then the final product will be always be disaster because it will be seen as a spear, fan or a rope.

Hence it is recommended that all actors of development process see the requirement from same lens and BDD Gherkin language provides that feature.

  • Different teams in the project need a common language to express requirements. This language should be simple enough to be understood by Business team members and should be explicit enough to remove most of the ambiguities for developers and testers.
  • This language should open up the thinking of team members to come up with more scenarios. As you express more details you try to visualize the system more and hence you end up making more user scenarios.
  • This language should be good enough to be used as project documentation.
  • Gherkin is a simple, lightweight and structured language which uses regular spoken language to describe requirements and scenarios.

Feature Files

Feature: Users should be able to login into Amazon Application with Valid credentials

In order to Login into the Application

As a Registered user

I want to enter valid credentials

Scenario Outline: Login into Amazon Application

Given I am on Amazon Website

When I Enter valid “<Username>” and “<Password>”

And I click on Login Button

Then I should see my account details

Examples:

| Username | Password |

| User1 | password1 |

| User2 | password2 |

Step Definition

@And(“^And I click on Login Button$”)

public void An_ I_click_on_Login_Button() throws Throwable {

// Express the Regexp above with the code you wish you had

throw new PendingException();

}

@Then(“^Then I should see my account details\”([^\”]*)\”$”)

public void Then_I_should_see_my_account_details(String arg) throws Throwable {

// Express the Regexp above with the code you wish you had

throw new PendingException();

}

A Feature File example gives clear picture requirement, behaviour and functionality.

In an Agile project a Business Analyst can write the requirement in Given, When & Then format and once requirement is refined then Developers & Quality Engineers can start coding the functionality.

  1. Cucumber (Java, Ruby, Javascript, Python)
  2. Jbehave(Java)
  3. Concordion(Java)
  4. Specflow(C#)
  5. EasyB(Java)
  6. Specflow(Ruby)
  1. Brings everyone on same page
  2. Reduce handovers
  3. Simplifies requirement traceability via feature files
  4. Test coverage gets easier with feature files
  5. Support progressive & regressive test automation
  6. BDD reports are easy to understand
  7. Supports Shift-Left approach

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store