Behavior-driven development is fast becoming a preferred method of software development for projects both large and small. John Smart, author of the book BDD in Action: Behavior-Driven Development for the Whole Software Lifecycle, offers a straightforward explanation of this technique. "BDD is an approach where you specify and design an application by describing its behavior from the outside."
The benefits of behavior driven development are many. Here are just a few:
- The process itself is lean since there's no tolerance for gold-plating
- It's highly fluid and can evolve to meet emerging requirements
- It encourages good communication with stakeholders
- It helps ensure the delivery of a product that really works
This outside-in development method can require some changes in how software designers and developers think about projects. Here are five quick tips for getting BDD right.
- Determine the requirements by having stakeholders describe how they expect the system to behave. Agree on concrete examples of what this would look like in real life scenarios to flush out incorrect assumptions.
- Turn the stakeholder's examples into acceptance criteria that define what is developed. Then, automate these acceptance criteria.
- Think of each layer of code as a client for another layer of code. A class that calls another class should be defined by its desired behavior. Turn these requirements into unit tests that are also described in terms of behavior.
- Ensure everything that's built contributes to implementing the expected behavior. Nip any fluff in the bud so all resources are directed toward meeting acceptance criteria.
- Create a continuous feedback look from the business to automated tests and back to the business in the form of test reports. When possible, make sure these reports are based on the original examples so stakeholders can see their goals being met.
And with these tips in mind, you can put behavior-driven design in action yourself!
What is your experience like with BDD? Let us know.