One Language - How Simple Do You Want It?

BDD comprises of 3 simple words - Given, When and Then.   These words are ONLY every found at the front of a sentence, and only once in a sentence.   

It is that simple!   Well its not that simple,  but lets look at these from a high level.

GIVEN

Given is your prerequisites.  Before going on to the next sentence, this sentence must be completed.  The most obvious of this is "Given I Am User Joe",  this means I am user Joe.   So if I log in as another user, lets say Mark, then this sentence should fail!  If I can't login as Joe, then I can't complete this sentence!  The test has failed at the first step.

WHEN

When is the actions.  When I Click On A Button, When I Load Web Page.   So any human interaction or any action from outside should start with When, and normally, if human interaction, the next work is I, as in When I <do something>.

THEN

This is your results.  What do you expect to happen or happened.  When I Click On A Button. Then Something Should Happen.   

So we have given, I've done something to get to this point, when, is when I do something, then is the result of that something!

In the academic world of BDD you are allowed to start your sentences with other words,  And and But - do not use these.  If you EVER use the word AND in a sentence, you should break the sentence down into multiple sentences

 

Take this example...   When I Click On Button "X" And Checkbox "Y".   This reads fine, but what happens if the failure is the Button or the Checkbox?  By having the "and" you are introducing a fog to the testing?  If you have 2 sentences When I Click On Button "X".  When I Click On Checkbox "Y", then there are 2 tests, and it is simple enough to for everyone to understand exactly where a sentence fails.  

You may also see...

Given I Am User Joe

And I Have Logged In

again in academic world BDD this is allowed, but if you are creating a list of tests (like visual studio) you may use a tool that uses intellisense. which gives options of the filling out the sentence you are using,  it can get confusing.. For example.. 

Given I Am User Joe

And I Have Logged In

When I Click On Button "Y"

And I Click On Checkbox "Z"

Then Cell Is Equal to "A"

And Cell Is Equal to "B"

In Visual Studio, as an example, if I type in "When", it will list ALL the BBD sentences that start with "When".  I can then type in Button, and it will list all the sentences that have When and Button...  "When I Click On Button", and you just select this.    If you type in "And", it does not know if that is a Given, When or Then, so shows everything.  You type in Button, you will be shown all the sentences with button in it.   By not using And, you help yourself in the long term.

Any conjunction word is making things difficult to find issues,  so I always recommend just use the BDD keywords, Given, When and Then only!

©2020 by Agile Testing.