Behavior-Driven Development is a software development process that puts feature behaviors first. Behavior specs become the requirements, the acceptance criteria, and the acceptance tests. Test frameworks can directly automate specs as well – declarative specs for unique product behaviors should be the units of coverage. The most prevalent BDD test frameworks are Cucumber derivatives that write specs in the “Given-When-Then” Gherkin language.
BDD is a full development process! Its practices complement Agile software development by bringing clearer communication and shift left testing.
Gherkin scenarios are meant to be short and to sound like plain English.It has various formats which can be read in our blogs “The Gherkin”
Automation & Framework Parts
Better automation is one of BDD’s hallmark benefits. In fact, the main goal of BDD could be summarized as rapidly turning conceptualized behavior into automatically tested behavior. While the process and the Gherkin are universal, the underlying automation could be built using one of many frameworks.
Gherkin feature files are very much part of the automation. They act like test scripts and each scenario is essentially a test case.
A step definition is a code block that implements the logic to execute a step. Step definitions can take in arguments, doc strings, and step tables. They may also make assertions to pass or fail a scenario. In most frameworks, data can be passed between steps using some sort of context object.
Certain automation logic cannot be handled by step definitions. For example, scenarios may need special setup and cleanup operations. Most BDD frameworks provide hooks that can insert calls before or after Gherkin sections.
Every automation framework has a driver that runs tests, and BDD frameworks are no different. The driver executes each scenario in a feature file independently. Whenever a failure happens, the driver reports the failure and aborts the scenario. Drivers typically have discovery mechanisms for selecting scenarios to run based on tag names or file paths.
Most BDD frameworks are Cucumber versions, JBehave derivatives inspired by Dan North, or non-Gherkin spec runners. Some put behavior scenarios into separate files, while others put them directly into the source code.
- C# and Microsoft .NET
- Java and JVM Languages
Which Framework is best?
There is no right answer – the best BDD framework is the one that best fits your needs. However, there are a few points to consider when weighing your options:
What programming language should I use for test automation?
Is it a popular framework that many others use?
Is the framework actively supported?
Is the spec language compliant with Gherkin?
What type of testing will you do with the framework?
What are the limitations as compared to other frameworks?