Community

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 support@hiptest.net.

Add Comment
No Comments

Leave a Reply

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

More DevOps stories

IBM Cloud Foundry Enterprise Environment (Experimental)

We're delighted to be working on a new offering in the IBM Cloud Foundry compute, called the Cloud Foundry Enterprise Environment. This offering provides a version of Cloud Foundry deployed into a customer's IBM Cloud account in any of our worldwide regions.

Continue reading

IBM Cloud App ID Technical White Paper – Now Available

We are happy to share that we have just published a technical white paper about building user authentication into your apps using IBM Cloud App ID. If you are deciding how to secure your applications with user authentication, this white paper provides a guide to the App ID service, and how to leverage it's capabilities.

Continue reading

From Concept to Multi-Tenancy in Hours with Zerto on IBM Cloud

Recently, we were having a routine call with one of our partners, a managed services company, based out of the United Kingdom. During the dying minutes of the call, the partner inquisitively inquired about a multi-tenant solution because it would open up another avenue for potential customers. Their current customers are beginning to understand the […]

Continue reading