You Are Now A BDD Expert

That is it!  Really it is!  

Take everything as one step at a time.  Watch the following Video...

Before going on, write down what you seen happen in the video.   If two people watch the video you will get two different works.  

Here is what I did (in my own words):-

I open Chrome, navigate to google.co.uk, search for Scotland, Find the Wikipedia link, and click on it.   

If you have not written down exactly what I wrote, is it wrong?  No, of course not, but can I follow it?  Now I'm not too sure.  Hence the need for BDD!   We all seen the same thing, but will write it down in very different ways!   Some, like me, just wrote it down, some will use Step 1, some may have another way.. some may have used BDD.

So from the video - we can create the following

Given I Have Chrome Open

Given I Have Internet Access

I have 2 Givens to start with, 2 places I can break down, before I've even done anything.   The next steps will be impossible to do, unless I already have Chrome Open, and it has internet access...  So these are my first prerequisites.   I should know (for a Given) how to open Chrome and to know I have internet access, but we will skip that for now and assume you have an idea how to get to this point.  But if you do not have Chrome, or have Chrome but no internet access, stop the test.. it will fail as you have not reached your prerequisite of the Given.

When I Enter "google.co.uk" In Address Bar

When I Press Key "Enter"

So now I have my interactions,  where I typed in the URL google.co.uk, and I pressed the return key to start the navigation.  There is 2 steps here,  I enter the text and then I press enter. 

 

I could write When I Enter "X" In Address Bar and then press Enter.  But look!  I've used the word then!  It should only be seen in the start of sentence, but also if this step failed, was it the entering the text or the pressing of the enter that failed?   We are testing 2 things here,  I can enter text in the address bar; I can press the enter key.

Then Page Contains A Link To "Scotland - Wikipedia"

Our first result!  In the list of websites there should be a link to "Scotland - Wikipedia".

 

The whole BDD becomes:-

Given I Have Chrome Open

Given I Have Internet Access

When I Enter "google.co.uk" In Address Bar

When I Press Key "Enter"

Then Page Contains A Link To "Scotland - Wikipedia"

All the sentences combine together to become a single paragraph.  In BDD we call these paragraphs, Scenarios.  We will look at these in more detail later.

But we did more, we click on the Scotland - Wikipedia link and it loads up that page.   So we start our new scenario with a Given, our prerequisites.  

Given Page Contains A Link To "Scotland - Wikipedia"

We know that if we follow the first paragraph, our last Then is "Then Page Contains A Link To "Scotland - Wikipedia"",  so to gain the prerequisite, the Given, we have to complete the first scenario.

This is how BDD builds up.    Each Given is a build up of Whens and Givens.  And repeat!  

©2020 by Agile Testing.