What is BDD/ Behavior Driven Development?
Behavior Driven Development is a process used in agile software development which makes use of business focused language to determine how an application should work. It is a branch of the principles that fall under TDD or Test Driven Development. A BDD framework is used to make software testing easily understandable for all in the team.
Closely related to TDD and ATDD, BDD aims to simplify the collaboration between the development, testing and business teams. In BDD, too, tests are written before writing the code. However, when making use of BDD frameworks, the tests are written in plain language so that anyone can understand it. Furthermore, these tests are explained in terms of how the app should ‘behave’ when the user is making use of them. Examples are made use of to ensure complete clarity. Essentially, BDD shifts the focus from test based to behavior based.
During the continuous testing cycle, BDD can be used for the automatic acceptance of cases. The expectations that the client has of the developer and testing team will be minimized by setting the cases at the start in an easy to understand format.
Now that you know what BDD is and a bit about BDD frameworks, it’s time to learn more. In the below sections, we’ve explained how BDD came into being, what the various BDD framework tools are, and the basics on how to implement BDD.
Past instances of the use of the BDD framework
Chris Stevenson wrote TestDox (aka agiledox) in 2003. This tool automatically generates simple documentation from JUnit tests. It is considered as the ancestor of BDD. Later, in 2004, the GWT or Given-When-Then framework was proposed by Chris Matts and Dan North. This expanded the scope of BDD to business analysis and documentation.
In the same year, North released JBehave, a framework for Behavior Driven Development. He did this to test his hypothesis about placing more importance on behavior than the tests themselves. A couple of years later, in 2006, Dan North documented this approach of his in Introducing BDD.
Over time, the app development community got more invested in BDD. This saw an increase in the release of BDD framework tools such as RSpec and Cucumber in the more recent years.
Applying BDD frameworks to software development and testing
Behavior Driven Development can be split into a few stages as described below. These are meant to eliminate any extra work by ensuring that the problems are dealt with early on.
- Discovery: Here, the various teams have a discussion about the various tests that need to be developed. The product owners, business stakeholders, end users, developers, testers and other teams all get together to define the business requirements as tests. The desired outcomes are defined.
- Development: Based on these desired outcomes, the software developers you hire work on building apps that behave in a certain way. This ensures that there is no failure.
- Revisiting: As the term suggests, in this step the various stakeholders revisit the app developed to ensure that the behavior is smooth. This also helps to ensure that only required features are built and there’s nothing unnecessary.
How to choose BDD frameworks?
To choose BDD frameworks accurately, it’s important to understand what exactly a BDD framework does. In the first step when using BDD, the stakeholders meet and discuss the various requirements. These are stated in plain language, usually Gherkin or other languages specified by the domain (DSLs). BDD test automation frameworks then read these executable specifications and perform tests to ensure that the software meets the needs.
Every major programming language has a BDD framework. The fundamental goal of all is the same and they are mostly derived from Cucumber and JBehave. Choosing BDD tools would depend on your particular needs. The following are some of the most popular BDD frameworks out there with an explanation of their offerings so you can choose with ease.
Cucumber is a non-technical language and makes use of the GWT (given-when-then) framework to structure the software’s behavior. It promotes the BDD practice and puts emphasis on clear requirements from the start.
SpecFlow is a famous BDD framework for Microsoft, .NET languages. SpecFlow needs a separate unit test runner to run the scenarios when making use of the free, open source version.
SpecFlow+, the premium version of the tool, has a BDD-friendly runner. It also comes with Microsoft Excel Integrations, premium support and living documentation. SpecFlow brings the same features to the .NET arena that Cucumber does to Ruby. The cases can be specified in a plain-English language in a readable format using Gherkin.
Meant for Java and related languages, JBehave is also a very popular BDD framework. It works smoothly with Scala, Kotlin and other JVM languages, too. It’s well known among both testers and developers. The tool comes with some features like parameter injections for parameterizing tests and composite steps.
However, JBehave does not offer all the same features as Gherkin does. Due to this, for Java and JVM based apps, Cucumber-JVM is also considered alongside JBehave.
When using PHP, Codeception is a popular choice for BDD testing frameworks. Along with BDD, Codeception also does full stack testing. This includes unit testing, API testing, and functional testing. The tool offers a more flexible dev-focused approach to testing.
How to pick a BDD framework based on the programming language you use
If you are looking for tools apart from the ones mentioned above, here are some suggestions based on your programming language: