• Mark Duffy

BDD Builds Up

Updated: Jun 4

We are starting to get technical with BDD, but honestly it is worth it!

Lets take a random application, "Facebook".

The first feature is the ability to log in. I want to supply a Username and Password and I want to successfully see my News Feed.

I'm going to start from the very beginning.

Given I Have An Open Browser
Given I Am Connected To The Internet

Next I Am Going to Navigate To

When I Enter "" In Browser Search
Then Facebook Is Open
Then Username Is Displayed

Now I login

When I Enter "" In Username
When I Enter "password" In Password
When I Click On "Log in"
Then I See "Marks" News Feed

Success! A simple procedure to log me in successfully.

But do I really want every test to start with 9 lines of text to say "success you have logged in!". That is going to get boring real quick.

The last line, the Then I See "Marks" News Feed. To get to that point I have to do the other 8 lines, but if I said

Given I See "Marks" News Feed
When I Click on Photots
Then I Can See Photos

I am saying, the prerequisites of this test, is that I can see Marks News Feed. The first test resulted in a Then I See "Marks" News Feed. So if I come across a prerequisite Given, I am sure to find a test that ended with the same Then!

In our example, to see "Marks" News Feed, I have to:- have an open browser, be connected to the internet, navigate to, enter my username, enter my password, click on login! Or I just write Given I See "Marks" News Feed!

We are done! I only once had to write the test that resulted in a Then, which I can use at any time as a Given.

Initially it is a big undertaking, moving to BDD. But it becomes exponentially quicker! You only need to write a complicated test once, which results in a Then... And every test you want to do that needs all those steps, becomes a Given...

When we talk about automation, this becomes invaluable! imagine you automate our Facebook login, you write the test once, you program it once, but every time a test has the Given I Am On News Feed , you are calling all the procedures, methods and functions that create the prerequisites of the Given.

One day, you can have

Given I Ran Regression Test
Then Regression Test Is Completed

Every BDD test you write, is a BDD test you never have to write again! Each test is a brick that never needs to be laid again!


©2020 by Agile Testing.