Behavior-driven development (BDD) is an Agile software development methodology in which an application is documented and designed around the behavior a user expects to experience when interacting with it. By encouraging developers to focus only on the requested behaviors of an app or program, BDD helps to avoid bloat, excessive code, unnecessary features or lack of focus. This methodology combines, augments and refines the practices used in test-driven development (TDD) and acceptance testing.Content Continues Below
A typical project using behavior-driven development would begin with a conversation between the developers, managers, and client to form an overall picture of how a product is intended to work. The expectations for the product's behavior are then set as goals for the developers, and once all of the behavior tests are passed the product has met its requirements and it ready for delivery to the customer.
BDD offers the ability to enlarge the pool of input and feedback to include business stakeholders and end users who may have little software development knowledge. Due to this expanded feedback loop, BDD may more readily be used in continuous integration and continuous delivery environments.
How behavior-driven development works
Behavior-driven development revolves around conducting behavior-specific tests, or functional specifications that outline executable scenarios for the application. This includes:
- Applying the 5 Whys principle or the if-then scenario to generate user stories and clearly relate application features to a business purpose.
- Identifying a single outcome for every behavior.
- Translating each scenario into domain specific language (DSL) to ensure accurate communication.
- Gathering all behaviors into one set of documentation so it is accessible for all developers, testers and stakeholders.
Behavior-specific tests can be run when a project starts, while a product is in development and when a product is completed. At a minimum, BDD requires that the behavioral tests (similar to unit tests) are created before development starts. Before development begins, all of the behavioral tests will fail, but as development of the product progresses, the tests will begin to pass. Once all of the behavioral tests are considered passing, the product is ready.