Behaviour Driven Development — 1/3 — Overview

A Scenario Example
  • Given : it’s the arrangement of context state — the starting state
  • When : it’s the event, a trigger or when a user does something
  • Then : it’s the outcome with the expected results

Reader’s guide

This article is part of a serie:

What is BDD ?

Behavioural Tests can be written for a system at any time: before, during or after development.

The BDD approach

The BDD approach is based on three major steps : discover, formulate and automate. The first on is quite important as it will drive all the work that follow.

Tres Amigos

The tres amigos concept relies on three perspectives - or roles:

  • Business
  • Development
  • Testing

Example Mapping

This discussion session, called an Example Mapping, is based on the tres amigos concept. People holding different perspectives should collaborate to discuss all the details, to define what to do and agree on how to do it correctly. The end result of such a collaboration results in a clearer description of the work leading to a shared understanding for the team.

Writing scenarios BRIEFE-ly

From the examples out of the example mapping workshop, we would likely write down many scenarios. Depending on the complexity of the feature or user story, we may end up with several scenarios. However, there are some best practices when it comes to formulate them. The BRIEFE principle may be of help.

  • Business vocabulary : use the agreed vocabulary among the tres amigos. That means anyone can understand. Avoid using terms that others can’t understand.
  • Real data — concret : use real data when explaining something, they serve as examples to represent the idea we want to tell.
  • Intention : A sample must have only reason to exist. Name it with intention.
  • Essential : A sample must help to understand the behaviour described in the scenario. If it does not, it’s useless.
  • Focus : There is only one interaction within a scenario.
  • Empathy : Samples describe what the user is trying to do, rather than what he does. This helps to understand and maintain. Describe the behaviour rather than prescribing actions. This aims to build empathy for a better user experience.

Benefits

Perhaps the greatest strength of Behavioural Tests is that they describe in a very direct way the set of the behaviours of what the user can expect from the system. The list behaviours taken together from a “contract” of the complete behaviours that the system is expected to exhibit. If all the Behavioural Tests pass then the contract has been upheld. If any of the tests fail, the contract will be broken.

Drawbacks

If all of this sounds too good to be true, it comes with some drawbacks:

  • Behaviour Tests tend to be a bit slower to run than unit tests
  • When they fail, they only indicate that something went wrong, but may give little or no indication of the root cause

The Pitfalls

  • One thing to avoid, because it is usually misunderstood, is to limiting three amigo discussions to only three people. The three perspectives are about roles, not about people. If there are other stakeholders who are relevant to a particular increment of work, include them in the discussion.
  • Also avoid expanding the three amigos discussions to the team. The intent of this practice is to include each necessary perspective with as small a group as possible. The smaller it is, the more efficient it is.

Unlisted

--

--

--

Developer, Coder or Craftsman, but code quality matters. Technical writer @wesquad @wemanity

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Git: Only if I hadn’t ignored this tool.

AWS Elastic Load Balancer

Creating a Highly Available Secured Kubernetes Cluster on AWS with Kops

TCP vs UDP, what’s the difference?

Overide notification in iOS via Firebase

Adobe I/O Events Adopts the CloudEvents Format

Terminal Usage and Basic Commands that you must know

Data Discovery done right

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kong To

Kong To

Developer, Coder or Craftsman, but code quality matters. Technical writer @wesquad @wemanity