There was an interesting discussion on the AgileSA Linked-in group around the use of BDD stories, and whether they should contain technical references or not. I found myself saying that I don't mind having, for example, a login story. To help Kevin Trethewey get over the shock and horror of this, I reflected on how my use of BDD stories has changed over time.
I remember Dan North explaining BDD stories to me when it was just a thought in his own mind. That was around 2005 or 2006 and I remember being so inspired by the simplicity of the BDD grammar. So, seven or eight years later, let me share how my use has changed. And, Kevin, I hope you enjoy your own journey too. It's a lot of fun.
Who is the best judge of a story? The customer is unlikely the best person to articulate these stories, nor judge the quality of the story. I have to guide them and extract that. I now ask the following questions.
- Who are they?
- What do they need?
- What do they think they need?
- What do they really want?
What does the story describe? Of the above questions, the last is the most powerful for me. It balances my perspective. It stimulates creativity and moves me from the problem space to solution space. The story then exists in the solution space; i.e. it is now reflects a design intention, not a requirement statement in the problem space.
BDD stories are great conversation artifacts. It's like a book on a coffee table. It stimulates conversation. It is of same value as using a metaphor. In conversation with the customer, the story is mostly about things in the problem space. In other words, it is an analysis and clarifying tool. I found that direct, literal and very early use of this analysis statement as an executable specification results can result in brittle tests.
On the use of technical references. When I'm working in the design space and writing design stories, then I don't mind if there is reference to a technical implementation such as a login screen. At some time, I have to get concrete. I like getting concrete very early and abstract from that. It's just how my mind works. So, if there is alternative authentication mechanism (say, LDAP or ActiveDirectory), then it is just another concrete implementation. If the authentication choice is an exclusive one, then, the abstraction of proprietary authentication and ActiveDirectory authentication doesn't offer any benefit. So, I'll just go for one of those and the story on task board will make reference to the technical aspects directly. It's a great reminder of a design choice that is explicit to everyone.
Most stories start out as bad stories. My early stories in an unfamiliar domain are awful. Like code, the story should exhibit single responsibility. That takes a lot of domain insight and discipline. Unfortunately, refactoring stories towards single responsibility is not trivial. It's not as simple as extract class/method/variable. The result is that my story based test suite is in constant turmoil longer than it is calm with a few small ripples. For this reason, I use the story grammar as a conversation piece, but not as code artifact.
BDD Stories on the backlog. To avoid confusion about when the story is in the problem space or solution space, I don't use BDD stories on the backlog. I prefer the XP style of a short phrase as a reminder of something to discuss.
On the use of outside-in style testing. I like outside-in to analyse the problem space, but I often find it equally valuable to evolve the design from the assertions inside-out. I oscillate between the two perspectives rapidly and quite often. I think I'm searching for that harmony in perspective. I then make it a choice to use the BDD story as an executable test for the outside in perspective. Often, though I find it unnecessary because I already have tests that reflect that perspective; it's just not using the BDD grammar. Yet, the BDD grammar was a starting point. I just am not fixated on the BDD grammar being the ending point.
On the BDD grammar. From a language perspective, the BDD template is a general grammar that can be used to express any domain. Just like we can use a general purpose language to solve any problem, the BDD grammar can be used similarly. Yet, we have learned that domain specific languages can be more expressive of a particular domain. Equivalently, I keep my mind wide open, looking for a story grammar that is domain specific. For example, in a time sensitive domain such as investment portfolios, I might extract a grammar that expresses time as a first class citizen. There won't be a "When" clause. I might have something like "At time t(0), the portfolio capital amount is..., at t(n) the portfolio has ..., at t(n+1) the surrender value should be ...".
Remember, these are just reflections and observations about myself. Please don't treat it as a gospel. You have your own journey that takes different pathways. Just enjoy those excursions.