BDD101 A Comprehensive Guide
BDD101 A Comprehensive Guide
BDD101 A Comprehensive Guide
Behavior-Driven Development
BDD 101: A Comprehensive Guide to Behavior-Driven Development | 1
Content
3 | What is BDD?
9 | Deliberate Discovery
11 | Example Mapping
17 | Continuous Integration
19 | Living Documentation
The deliberate discovery phase brings together In the Agile development cycle, BDD processes
key stakeholders to have conversations and come usually take place when you’d normally come up with
up with concrete examples. Product owners, acceptance criteria. The process involves converting
| Jasmine: Jasmine is the most popular BDD using the strategy. This means that you should
never be writing tests after writing code since the
automation framework for JavaScript applications,
tests aren’t driving the implementation in that case.
which are becoming increasingly popular in
startups. “ BDD introduces unnecessary complexity.”
| Easyb: Easyb is a BDD automation framework
Many developers already use test-driven
designed for Java, which is widely used across
development, which includes unit and integration
enterprise applications.
tests. These processes may already test user
| Behave: Behave is a BDD automation framework
interfaces with automation frameworks, like
designed for Python, which is commonly used
Selenium and Capybara. Some developers see
for data-driven and scientific applications.
business readable language as an unnecessary
| Behat: Behat is a BDD automation framework step that slows down the test suite. But the two are
designed for PHP 5.3+, which is used across completely different: BDD is about collaboration,
many legacy web applications. not testing automation.
Domain-Specific Languages (DSLs) “ BDD will take longer and delay projects.”
| Gherkin: Gherkin is by far the most popular
BDD introduces some extra meetings to ensure
DSL used by BDD automation frameworks.
that business and technical users are on the same
page, but these meetings don’t have to be very
Common Misconceptions
long and they can help your team be much more
“ BDD is just a testing framework.” productive over the long-term. These meetings
Behavior-driven development is not a testing also ensure that developers aren’t wasting their
technique, it’s a development strategy. It’s the time writing the wrong code. We will see in the next
process of thinking about the user experience and section how BDD can help deliver real benefits with
application programming interface, or API, before a minimal time commitment.
technical teams closer together, release software in criteria — or rules that let managers know
more frequent cycles, and adapt to evolving custom- when a user story is functionally complete
er needs rather than sticking to a plan. The result — varies in quality. Often times, there’s not
is better software projects that more closely match enough information to create reliable tests for
expectations — resulting in fewer canceled projects. use in test-driven development.
it’s easy for developers to go down a different stories and acceptance criteria and transforms
path than business analysts imagined. them into a formal set of features and examples
that can be used to generate documentation,
| No Overarching Test: Test-driven development automate tests, and a living specification. In other
can ensure that the technical components of words, it gets everyone on the same page and
an application function as expected, but there’s ensures that there’s no miscommunication about
nothing that ties all of these components to- how the software behaves or what value it provides
gether to ensure that the software delivers real to the business.
business value.
At the very least, BDD is worth a try for almost any
BDD places a heavy emphasis on concrete ex- software project that requires input from stake-
amples to reduce ambiguity in user stories and holders and business people. It’s a great way to
acceptance criteria. In addition to getting on the dramatically cut down on the waste that’s typically
same page, these examples help uncover gaps that seen in software projects while ensuring that
nobody had considered before the functionality they’re delivered on time and on budget rather
is implemented. The feature files generated in the than becoming a statistic. The tests that you write
BDD process also serve as living documentation will also be a lot more understandable and mean-
for the application, showing how it’s supposed to ingful to everyone on the team.
function in a human-readable fashion.
Discovery inception to delivery? Now, imagine that you could using concrete examples — and assuming igno-
do the same project over with everything kept the rance. For example, a user might ask: Will my reply
same — except your team would know everything appear in my Twitter feed for anyone to see? The
original user story and acceptance criteria may not
they learned during the original project. How long
have specified the answer to that question, but it
would the second project take to complete? The dif-
would clearly have a big impact on the architecture
ference between these two scenarios tells you that
of the overall application.
learning is the constraint in software development.
Rather than building software and putting it in front
Deliberate discovery is the first step in
of users to get feedback, the goal of deliberate
behavior-driven development: Learning as quickly
discovery is to try and learn as much as possible
as possible to remove the constraints on a project before writing any code to minimize waste and
to deliver on time and on budget. maximize productivity.
1. 2.
What is Deliberate Discovery? Who Should Be Involved?
Most software development teams are familiar with Deliberate discovery processes should involve as
user stories and acceptance criteria. For example, many different team members as you need to provide
a user story for Twitter may state that a user can insights into their specific areas of expertise. De-
reply to another user’s tweet. Acceptance criteria velopers may think of features on a very technical
help define the specifics of how that functionality level, whereas domain experts may have insights
will be implemented, such as the presence of a re- into what actual customers are looking for in terms
ply button on the first user’s profile. The problem is of functionality. All of these insights are critical
that these two tools — user stories and acceptance for reducing the uncertainty around features and
criteria — don’t explore any unknowns. ultimately meeting the software’s business goals.
| Domain experts wrong code. testers. The goal of these meetings is to generate
At the core, the most important outcomes of these 2. Rules: The acceptance criteria for the user
meetings are concrete examples that can be turned story that contain agreed-upon constraints
into executable specifications, and ultimately, about the scope of the story, and summarize
automated tests and living documentation for the the underlying examples.
software application.
3. Examples: These are the concrete examples
Example mapping is one of the most popular strate- covering each rule. There can be more than
gies to come up with these concrete examples one example per rule to cover different
potential use cases.
during deliberate discovery meetings. In addition to
coming up with examples, the process helps uncov- 4. Questions: These are unknowns that arise
er any unknowns or uncertain assumptions. when exploring the rules and examples or
assumptions that were made in the interest
How Example Mapping Works of moving forward.
Example mapping was developed by Matt Wynne Matt suggests using a pack of four-color index cards
after he noticed that many deliberate discovery and some pens to capture these different types
meetings were long, boring, and unstructured. His of insights as the conversation unfolds, and then
goal was to introduce a simple, low-tech method arranging these index cards in a map.
that could make these meetings short and produc- The low-tech approach is designed to eliminate any
tive. The example mapping process includes four distractions and keep the team focused on having a
components: meaningful conversation.
narios
that simulate how users would actually be using with “Acme Project”
with Cucumber. selection of automation frameworks and tools of any | Loose integration avoids integrating auto-
BDD platform. By defining individual steps describing mation-related content inside of scenarios
Automating the Process the actions that are performed, you can avoid the and action words. The specific implemen-
need to go in and write any test code — or at least re- tation is left up to the automation team to
There are many tools that automate the process of
duce the amount of test code that you need to write. complete for the test code to run.
building step definitions. These tools can speed up
the development process by automating work for For example, you could define “Click on Profile” by | Tight integration defines specific class
test engineers, while ensuring that all step defini- setting a specific target, such as “a[text=”Profile]”, that names and other details to make the tests
tions are consistent in their design and usage. will look for any link with the text “Profile” on the page. run out-of-the-box. That way, the testing can
These steps can also include variables, although the be completely automated.
Export
Important Considerations
It’s important to watch out for blind spots when con-
verting higher level feature files into lower level execut-
able step definitions.
tion, deployment, and delivery, which automatically that stakeholders can be confident in deploying
ensures that any new code passes the appropriate new features without worrying about costly
Let’s take a closer look at continuous integration, | Greater Visibility: Everyone can see the proj-
how it fits into development workflows, and how to ect state in the shared code repository, which
better integrate BDD into the process. enables a better feedback cycle.
automatically deployed. mobile platforms, including iOS and Android. | Publish the results back to CucumberStudio
using the step-by-step guide to ensure that
The workflow can be customized depending on | Jenkins: The leading open source automation
everyone is on the same page.
the needs of the organization. For example, some server with hundreds of different plugins to
teams prefer to deploy automated builds to a stag- support building, deploying, and automating
posed to do and proves that it can do it. create documentation for users that makes it
easier for them to use the application, or help
Let’s take a look at how to leverage the scenarios
troubleshoot common problems. For exam-
and executable specifications created during the
ple, Stripe’s legendary API documentation was
BDD processes discussed earlier to create a living
critical to its success.
documentation.
| Better Workflow: Operational documentation
Why Documentation Matters helps stakeholders communicate their vision to
development teams. For example, user stories,
Documentation is instrumental in keeping stake-
acceptance criteria, design documentation, and
holders, developers, and users on the same page.
other resources provide context to the code.
While documentation may seem to counter Agile
development principles by creating more work The amount of documentation required for a
upfront, the process actually reduces the total work project is where there’s always some confusion.
by ensuring that everyone is working together more Agile development focuses on writing as little
effectively. There’s no time wasted from miscommu- documentation as possible early on, while
nications and it’s much easier for everyone to get traditional waterfall development writes all of the
up to speed. documentation at the onset.
they should be able to look at scenarios and see proving communication, these processes minimize
whether the step definitions have passed. If a mistakes, reduce errors, and ensure a higher quality
developer wants to know the status of a feature, product reaches users.
they should be able to run a test and see whether
CucumberStudio makes it easy to implement and
it has passed.
automate BDD processes with minimal coding,
Building Living Documentation making it accessible to both business and technical
CucumberStudio automatically generates up- teams. With its easy-to-use interface, it’s the per-
to-date documentation when integrated with a fect solution for teams just starting out with BDD
continuous integration platform. Every time a BDD processes. The many features and integrations
scenario is added and successfully run, the scenario also make it perfect for established teams looking
is automatically added to the human-readable living for a more streamlined approach to implementing
documentation. This documentation can be easily BDD across their organization.