visit
What I discovered made me realise that I didn’t actually know very much about BDD at all…
And here’s an oft-quoted :
…having conversations is more important than capturing conversations is more important than automating conversations.In the conference talk I mentioned by Liz Keogh, she even reports a conversation with Dan along the lines of “it’s a shame we made it so easy to create automated tests from examples, because now everyone thinks that’s what BDD is about”. Guilty as charged! I was aware of some of the broader implications of BDD, but wasn’t seriously engaged with them. Writing executable specifications and creating automated tests from a user perspective is incredibly valuable, and I’m definitely going to keep doing those things, but there’s more to BDD than that.
So, if BDD is actually a process for the full software-development lifecycle, what else does it cover? Here are some of the bigger pieces of the puzzle:
One of the key BDD principles is to focus on business goals, and to only work on features that will help achieve those business goals. BDD pioneer Chris Matts invented a process called Feature Injection to help you do this:
Essentially, you start by working out your business goals, and then from those you “inject the features”, proactively looking for features that will deliver those business goals. This is fundamentally different from devising a big backlog of stories and then trying to prioritise them in relation to goals. It’s also different from User Story Mapping, which arranges your stories to walk you through a first version of the system. With feature injection, everything flows from the goals, rather than the goals being simply a guiding principle when working with stories you derived when thinking about a system. The third stage of Feature Injection is to “spot the examples”, using high-level examples to flesh out the missing scope of the features identified.(Whilst this suggests that there are only 3 “levels” of description of a system — goals, features and examples — BDD actually defines a fuller set of levels which go all the way down to code and include other steps in between. Read BDD in Action for more on this.)
Another process which BDD practitioners use to keep this explicit link to business goals is Impact Mapping, invented by Gojko Adzic. You can read more about it at
Two more important BDD principles are Real Options and Deliberate Discovery. These allow you to embrace uncertainty and change in your projects.
In short, Real Options is the idea that you shouldn’t commit to a solution until the “last responsible moment”, waiting until you have maximum possible certainty that it’s the right one. But this doesn’t mean putting of decisions forever — decisions should be at the last responsible moment, not just the last moment!
Deliberate Discovery is the other side of this coin, taking seriously your own ignorance about which solution to a problem is the best. In a nutshell, Deliberate Discovery says that you should aim to identify and reduce uncertainty by proactively investigating areas of ignorance about a possible solution. You can read more about Feature Injection, Real Options and Deliberate Discovery here:The key reason for creating scenarios (structured natural-language descriptions of user actions) is not so that you can created automated tests from them. In BDD, the key reason is the conversations that happen when a developer creates those scenarios together with a Business Analyst and a Tester (a “Three Amigos” session). And, even more than that, it’s the increased understanding of what the system actually needs to do that comes from those conversations.
Of course, you can still go on to automate the scenarios, but that’s a secondary benefit.The behaviour-driven development “double loop” Now, the Acceptance Tests that you write first are based on the examples you’ve already derived, which come out of the processes I talked about earlier (crucially, from conversations and shared understanding), so you should be able to trace the thread back from here to the business goals. I was doing the left-hand part of the loop right.
However, although BDD practitioners do talk about “Unit Tests”, to take BDD “all the way down”, I needed to start thinking less about unit-tests and more about low-level executable specifications (Acceptance Tests being the high-level executable specifications). This might sound like a simple difference in phrasing, but there’s more to it than that:
In BDD unit testing you focus on specifying (and thus testing) the behaviour of the class, rather than testing it method-by-method. This “outside-in” approach is a parallel of what you do with your automated acceptance tests at the higher level.
(Interestingly, this idea of outside-in unit testing has similarities with the so-called “” of TDD, but I’ll save the comparison of those for another time!)As part of the shift away from unit tests and towards low-level executable specifications, you’ll want to write in something closer to the structured natural language used in your application-level BDD scenarios. There are plenty of tools around which allow you to do that at this lower level. Here’s an example from the manual:
PHPSpec, and other “xSpec” tools like it, can generate nice natural language output similar to that shown at the start of this article.
But you can do BDD at the low-level with “traditional” unit-testing tools too. Here are some principles from BDD in Action to help you do that:
Making more use of BDD reporting tools, however, we could aggregate scenario results at the feature level, showing when a complete application feature was ready to deploy (i.e. all tests were passing).
“Feature coverage” is an even more interesting idea — showing progress through a whole project by seeing how many acceptance criteria have been defined and automated for each requirement, including reporting on those which have no AC yet. To make the most of this, we’d need to combine a BDD reporting tool with our project-management tools, so that details of non-started stories could be retrieved.
This would be quite a major process and technical undertaking, however. In fact, almost all of what I’ve described so far has repercussions on process throughout a large part of our business, going way beyond development. So what am I, as a Tech Lead, going to do about all of this? That’s what I’ll explore in the final section.At White October, we’ve always prided ourselves on working “unusually closely” with our clients — we don’t have business analysts between developers and clients — clients are full team members from the word go, and work directly with developers and designers (among others). Do we really need new processes to help us adhere to the principles that BDD espouses or are our existing process doing that already?
As mentioned, we don’t have business analysts. As a small company, we don’t have QA staff either; the QA role is shared around different team members at different time. This means that a “3 Amigos” example-writing session — with Business Analyst, Tester and Developer — could end up being just one person! Of course, we’d bring in the client themselves rather than a BA, and a designer would be a natural replacement for the Tester role here — they have a different perspective which would really help. But would clients really be willing to commit to the level of involvement example-writing would require? This is quite different than running the meeting with solely in-house staff.
Part of the answer here is to say that uncovering examples via conversations is different to (and quicker than) writing the formal scenarios, but does that make it legitimate to write scenarios unilaterally?
We pride ourselves on doing Agile well, and that gives us strong emphasis on embracing uncertainty and change already. Do we need to adopt new techniques like Real Options to do this better?
As a developer, I like the idea of programatically tying together different tools, linking our project tracking software to outputs from our automated behavioural tests (as discussed in the living documentation section above). However, as a small company, do we need heavy processes to help us track progress better, or can we just rely on manual processes and conversations as at present?
Although the questions in the previous section might make me sound like a skeptic, they’re more accurately seen as a reflection of the fact that I’m keen to engage seriously with BDD and what it means for us. I’m passionate about the principles of BDD and really pleased to understand them so much better now.