Deliver better software faster with Behavior Driven Development

Share this post:

In the context of digital transformation and dramatic acceleration of software deployments, working in silos (Business, Developers, Testers, IT…) is no longer an option. Agile, and now DevOps culture, are getting a lot of traction as they break silos with cross functional teams. Therefore, rapid iterations and quick feedbacks are king.

For organizations deploying new software in production several times a day, one of the most challenging transformation issues is the need to revolutionize testing. In an era of continuous deployment and updates, there’s no time to have QA teams identify a problem and kick it back to the developers. The times are gone when you could test your app after the development and before going in production.

This is where Behavior Driven Development (BDD) comes in. BDD is a powerful approach that enables your team to align on the definition of what should be built, and when.

First, the developers, testers and business analysts explore the problem domain, and collaborate to produce concrete examples that describe the behavior they want.

Every test should tell a story about your application

These examples define the boundaries of the user stories and are designed prior to the development. It’s a great way to minimize waste and avoid development of features that are not needed, or that do not meet business expectations.

These concepts are quite simple and were initially formalized by Dan North.

Using BDD with Gherkin syntax

Gherkin is plain-text language with extra structure included to make it easy to learn by non-programmers. It allows concise description of examples to illustrate business rules in most real-world domains. One of the biggest advantages is that it clearly highlights the intent of the example/test development application.

You can follow these basic steps to begin using BDD and Gherkin syntax:

  1. Start with your user stories.
    • As a team, go through your user stories and write BDD scenarios using the keywords GIVEN, WHEN, and THEN (AND, BUT can be used as well)
    • GIVEN is your setup. For example: “GIVEN the credit card is valid”
    • WHEN is your action. For example: “WHEN I request $50”
    • THEN is your assertion: For example: “THEN the ATM should dispense $50”
    • Capture the BDD scenarios in a location that is public for everyone to see. Hiptest is a good choice 🙂
  2. Automate your BDD scenarios.
    • First, the execution will fail as the feature is not yet implemented
    • Automation clearly requires development skill. You’ll want to learn how to build a test automation framework that scales.
  3. Implement the features
  4. Run the automated BDD scenarios to show the feature is completed
  5. Repeat

Here is a sample Gherkin document:

<span class="k">Feature:</span><span class="nf"> Account Holder withdraws cash

Scenario: Account has sufficient funds
Given the account balance is $100
And the card is valid
And the machine contains enough money
When the Account Holder requests $20
Then the ATM should dispense $20
And the account balance should be $80
Then the card should be returned

The next post will focus on a step-by-step implementation of BDD with Bluemix and Hiptest.

If you have any questions, or would like to chat further about BDD please reach out to

Add Comment
No Comments

Leave a Reply

Your email address will not be published.Required fields are marked *

More DevOps Stories

Cloud Foundry Day – London England, Nov 29th

Come join us for a "Cloud Foundry Day", a free educational conference and networking event with talks by Cloud Foundry community members, industry leaders, and Cloud Foundry Developers. Hosted by Dr. Julian Friedman, IBM Open Source Development Lead, code contributor and a leader in the Cloud Foundry community, and joined by renown speakers in the Cloud Foundry community. Enjoy some great topics, good conversations, food and beer!

Continue reading

WEBINAR: Join IBM Cloud and F5 on Nov 15 for “Multi-Cloud Made Easy”

One of the greatest strengths of IBM Cloud’s partnership with VMware is our expanding ecosystem of best-in-class partners. F5 is the newest member of this alliance. In addition to IBM Cloud’s global reach – an unparalleled 60 data centers worldwide and growing, flexible purchase and deployment options for IBM Cloud for VMware Solutions and extensive […]

Continue reading

Protect your data to simplify GDPR Readiness

The EU General Data Protection Regulation will come in force in May 2018, everyone is in a scurry to get ready and get ready fast. The GDPR brings with it potential fines for non compliance but also brings an opportunity for businesses to enhance their business and brand value. We see our customers are interested in two aspects. First, what is IBM doing for their own GDPR readiness, we recently published our own readiness journey. The second aspect is what IBM can do to help clients with their readiness program?

Continue reading