Recently I’ve had the opportunity to speak with a broad range of Agile coaches and consultants who have consistently told me that they have not seen any organization successfully adopt BDD as part of their standard process of elaborating their User Stories.
Luckily I have had the opportunity to work with several organizations that were able to successful adopt BDD and believe strongly in how this process can transform how you build and bake quality into your products.
I think most people hear the word BDD and they immediately think that it is an automation centric effort, though that is a great value add for BDD, leveraging BDD without automation can also lead to improved testing and quality.
Adopting BDD is so much more than automation (which I wrote about here) it’s really about clearly defining the expected behavior of your system.
Why is this so important? Because as humans we all interact differently with the systems that we encounter. As people who develop these systems we deliver based upon our experiences and understanding of the system we are building.
Language (Business Requirements) has been the manner and method that we have used to convey what we want a system to do to. However with an international work force we don’t all have a shared language. In addition to this constraint we also interpret what we read differently based upon our primary language, life experiences and culture. Given this, it’s not surprising that when we build a system, it has many different interpretations attached to it, which negatively impacts both the functionality AND quality of our system.
BDD is a way to talk about how your system should behave not what it should do. Yes we want our systems to have specific functions and features, but talking about how each of these will behave brings about a much richer conversation of what can happen in many functional situations the system and the people will encounter, not just the happy path.
There are two primary components of BDD:
- The Given/When/Then test setup
- The Example Table
Getting the first part of your BDD is the most important component because it defines the size and scope of what the User Story. We do that by decomposing an individual user story into Test Scenarios. One quick way to determine if your user story is perhaps to large or complicated is to evaluate the number of Test Scenarios you can define. Keep your Test Scenarios to under 4 per each individual User Story so that you can more easily understand the expected behavior for that part of your feature or functionality.
Keeping the number of test scenarios small is also important once you translate your BDD into test automation which will keep your tests small so when something breaks it is much easier to find out where you need to address a fix. Remember development teams should be consistently refactoring their code to improve code quality. With high levels of automation we can quickly catch when refactoring unexpectedly changes the underlying behavior of our system. This is where Quality is kept front and center in our organization.
The second part of building effective BDD is the Example table. My training focuses on getting the first part clear and clean because the example table is an easier effort of filling in the expected results in each of your parameter columns. As with the first section you can use the number of parameter columns as a means of determining if your test scenario is too large. Try to keep the number of parameters to between 4-8, anymore will result in more brittle tests and more time debugging your automation code.
Adopting BDD as your primary means of decomposing stories may on the surface seem like a lot of work, but remember that you are only doing this level of detail for each 2 week sprint so the number of stories that you build out context driven BDD is relatively small. Doing it every sprint means you get better at it every time and you will refine your ability to generate BDD much more quickly.
We should also remember that this is a TEAM oriented approach, don’t relegate this to your QA team, you will miss getting all of the context needed to delivery high quality code and functionality.