behavior driven developmentThere has been a lot of information published about Behavior Driven Development or BDD.  It is counter to what most people are used to so it causes a lot of confusion.  It is very popular and a lot of organizations have started to embrace this methodology which results in great success to those who can consistently apply some basic principles.  Behavior Driven Development allows companies to shift further left and identify issues much earlier in the process than using the traditional waterfall methodology.

What is BDD?

Behavior-Driven Development is an extension of Test-Driven Development or TDD.  Behavior-Driven Development is an approach to build features based upon user stories.  You will typically have a product owner that will communicate the expectations for the software in form of a user story.  That information will be stated in terms of business objectives or goals.  Both the developer and the tester will use this information to both develop and test if these features meet the expectation of the product owner.  While BDD is a process, just like any process it requires great communication between all members.  What does the product owner want to see?  How can that be translated into software features?  Are those features really needed or are there other features that might meet business needs.  Behavior-Driven Development heavily relies on communication and collaboration which are also one of the key tenants of Agile.

BDD Testing

Behavior Driven Development premise is that the tests are written before the code is developed.  In basic terms it tells you how a piece of code needs to be tested.  You want to test the behavior of a given feature.  It is extremely important to do this first so that you will have a high degree of testing coverage.  BDD requires the person who is creating the tests to think about the business scenario.  As you build code, you are building a very large repository of tests which can be executed over and over again using tools such as Jenkins.  Now you might wonder if the developers are writing all these tests, why are testers needed?  Well testers are needed more than ever.  Developers are often focused on a small module or piece of code and don’t have an overall understanding of how the system works as a whole.  Testers typically have a broader understanding and are usually business subject matter experts.  It is important for testers to understand the broader context of the what and why of software and the business intended use.

Three Best Practices of BDD

  1. Discover: The first best practice is the most important one in my opinion.  Created a shared understanding across the business and the Agile team of what the requirements are through collaboration.  This is a critical step, and one that most Agile teams will overlook and rush to build tests and code.  This collaboration needs to occur through structured conversations using specific rules and examples.
  2. Define:  The second best practice is to use real world business scenarios and document how the system should behave.  This documentation reinforces best practice 1 and 3.  The most commonly used framework for defining scenarios is Gerkin.
  3. Automation:  The third best practice is to automate the documentation.  This will allow the documentation to grow and become dynamic.  This process will verify that the system works as expected and verifies best practice 1 and 2.  Most teams today use Cucumber to automate BDD tests.

BDD Framework Process

Here is a sample flow of how things work within the BDD framework:

  1. Create a user story with high level functionality
  2. Hold a requirements session and further define functionality with business examples
  3. Define business scenario using Gerkin
  4. Automate the scenario using Cucumber
  5. Write code so that the test scenario will pass
  6. Run additional tests including regression, performance, etc.
  7. Release code into production

I hope this information has been helpful and has provided you with some great information about Behavior Driven Development