Behaviour Driven Development (BDD) is: “a second-generation, outside–in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters.”
– Dan North, Agile Specifications, BDD and Testing eXchange
Lately, I’ve had a lot of discussions with people about Behaviour Driven Development and what it means to them. I have always taken something different away each time, including some things I feel are misconceptions. BDD is not about testing in the traditional sense of the word; it does not replace the need for testing or a QA process, and it is not a set of tools that can be used as part of your test suite.
Konstantin Kudryashov (@everzet), creator and maintainer of Behat, has given many talks on BDD, and I feel he provides a clear message and definition of what the actual practice is about. Here is my understanding of BDD based on those talks.
In a typical software development project you will have three ‘entities’ or ‘roles’:
Feedback is then given to the client in the form of working features, creating an opportunity for the client to talk to the delivery team. However, at each stage this communication can easily be misinterpreted by both the client and the delivery team (and in traditional development projects, it often is).
Communication, therefore, must happen at all levels. The delivery team need to understand the client’s requirements and ask them why they need a certain feature, then understand its job and who benefits from it.
The time and cost of not understanding or misinterpreting the client’s requirements or the delivery team’s feedback is known as the “cost of translation” or the “feedback delay”. If misunderstandings aren’t addressed in time by the delivery team, they could spend anywhere from a couple of weeks (using Agile) to years (using Waterfall) developing a solution that does not fulfil the client’s actual requirements.
BDD is a practice that can help solve this problem of miscommunication between the client and the delivery team.BDD attempts to eliminate the cost of translation by reducing the size of the feedback loop and enforcing example-based conversations for each feature before it is built. This enables the delivery team to ask for examples from the client; clearing up any misunderstandings that may have occurred and ensuring conversations with the client typically happen within days (not weeks or years).That in essence is what BDD is.So to recap, BDD is about eliminating translation costs between the client and the delivery team using the language of examples.
But just asking for examples is not enough, because different sides will use different languages to produce examples, which will inevitably cause discrepancies. This is where the Ubiquitous Language helps.
“Ubiquitous Language is the practice of building up a common, rigorous language between developers and users. This language should be based on the Domain Model used in the software – hence the need for it to be rigorous, since software doesn’t cope well with ambiguity.” – Martin Fowler
BDD gives the delivery team the ability to have conversations with the client on a business level, and in doing so allows them to come up with ideas on a non-technical level that will help solve various project challenges. The delivery team can then go off and write code for the client which fits with what was previously discussed. Decisions won’t get made at a coding level but will instead naturally get fed back to the client and discussed as a group as part of a collaborative effort – helping build “software that matters”.