Behavior Driven Development
Behavior Driven Development is an Agile software development technique
focused on improving a key factor in the successful development of any software
product: Communication. It is a technique devised by Dan North as a response to
the issues he encountered whilst teaching Test Driven Development. Eric Evans
describes it this way in his book Domain Driven Design: “A project faces serious
problems when its language is fractured. Domain experts use their jargon while
technical team members have their own language tuned for discussing the domain
in terms of design… Across this linguistic divide, the domain experts vaguely
describe what they want. Developers, struggling to understand a domain new to
them, vaguely understand.”
He goes on to describe the concept of modeling a system using a
ubiquitous language based on the business domain, so that the business
vocabulary permeates right into the codebase. BDD seeks collaboration amongst
the delivery team and business participants in a software project. On the “Agile
specifications, BDD and Testing eXchange” in November 2009 in London, Dan North
gave the following definition of BDD: “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.”
It is a framework based on three Core Principles:
1. It’s All Behavior: Business and Technology should
refer to the same system in the same way
2. Whereas The Business Value: Any system should have an identified,
verifiable value to the business
3. Enough Is Enough: Up-front analysis; design and planning all have a
diminishing return
Behavior Driven Development centers on obtaining a clear understanding
of desired software behavior through discussion with stakeholders. From this
initial discussion between the stakeholder or users and the business analyst
comes a list of features of the system to be developed, features also known as
“User Stories” in our Agile environment. They describe the behavior from the
perspective of those interested in the product.
The format is:
As a [X], I want [Y], so that
[Z]
Where X is the person (or role) who will benefit , Y is some feature ,
and Z is the benefit or value of the feature. Its strength is that it forces you
to identify the value of delivering a story when you first define it. This can
make it easier to descope some of the more esoteric requirements.
The next step is writing test cases in a natural language that
non-programmers can read, specifying scenarios of system behavior. A scenario
describes the feature acceptance criteria. We call scenarios “acceptance tests;”
they express what the software needs to do in order for the stakeholder to find
it acceptable. So, everyone on the team, including stakeholders, writes these
tests collaboratively, because they not only decide the system behavior, but
they learn how to describe that behavior in a common language that everyone
understands. If the system fulfills all the acceptance criteria, it’s behaving
correctly; if it doesn’t, it isn’t. So a template can be created to capture a
story’s acceptance criteria.
The template had to be loose enough that it wouldn’t feel artificial or
constraining to analysts but structured enough that we could break the story
into its constituent fragments and automate them.
The next step is to automate these scenarios as examples,
taking the following form:
Given – some initial context (the givens)
When an event occurs,
Then ensure some outcomes.
Acceptance tests written in this style become more than just tests:
they are executable specifications and living documentation. When the
software system is continuously validated against a set of executable
specifications, the team ensures that the system will do what the specifications
say. Or, to put it differently, the specifications will continue to describe
what the system does.
They have the following benefits:
- Living documentation replaces all the artifacts that teams need for delivering the right product.
- We can continue defining specifications as the system grows up, in an incremental way.
- They are cheap to write.
No comments:
Post a Comment