Building Up BDD

The most common BDD expression I have ever seen is...

Given I Am User "Mark"

This prerequisite normally means, I have already logged in as the user Mark.   I can now do something.   

But how did I get this Given, and surely logging into one system is different from another?   And the answer is ... EXACTLY!   Say I have two applications, one asks for a username, a password, and a domain, it has a OK button,  the other asks for a username and a password and has a Login Button.

Both system have a Given I Am User "Mark" as the most common BDD expression, but how can it be the same thing?

Lets start with application 1,  we build up the BDD by...

Scenario 1

Given I Chrome

Given I Have Internet Access

When I Navigate To Application 1

Then Cell "username" Is Displayed

Then Cell "password" Is Displayed

Then Cell "domain" Is Displayed

Then Button "OK" Is Displayed

Scenario 2

Given Cell "username" Is Displayed

When I Enter "Mark" In Cell "username"
Then Cell "username" Is Equal To "Mark"

Scenario 3

Given Cell "password" Is Displayed

When I Enter "marks password" In Cell "password"
Then Cell "password" Is Equal To "marks password"

Scenario 4

Given Cell "domain" Is Displayed

When I Enter "marks domain" In Cell "domain"
Then Cell "domain" Is Equal To "marks domain"

Scenario 5

When I Click On Button "OK"
Then I Am User "Mark"

5 scenarios, and that gets me to the Then of me being User "Mark". If I see the sentence "Given I Am User Mark" then I know this is what I have to do to get to that given.   One sentence = 5 scenarios, 18 sentences, same result!

On application 2

Scenario 1

Given I Chrome

Given I Have Internet Access

When I Navigate To Application 2

Then Cell "username" Is Displayed

Then Cell "password" Is Displayed

Then Button "Login" Is Displayed

Scenario 2

Given Cell "username" Is Displayed

When I Enter "Mark" In Cell "username"
Then Cell "username" Is Equal To "Mark"

Scenario 3

Given Cell "password" Is Displayed

When I Enter "marks password" In Cell "password"
Then Cell "password" Is Equal To "marks password"

Scenario 4

When I Click On Button "Login"
Then I Am User "Mark"

Our one sentence is exactly the same for both applications, but in application 2 the sentence "Given I Am User Mark" has 4 scenarios, 14 sentences.  But same outcome, I am logged in as user Mark!

People always then jump to point, "so when developing BDD you need to start from the vary start?  From the very login?"  And the answer is no,  you can start anywhere you want.   Lets launch a rocket!

 

 

 

 

 

 

 

 

 

 

 

 

 

We can easily start our BDD from any point in time.  

Given We Are On Final Count Down

Then We Have 10 Seconds To Go

If you know how to get to Final Count Down, this is totally acceptable!  Encouraged even!  You do not need to go back to, asking Congress for money, making a the rocket, choose the pilot, and so on...   You might not want to test/BDD this part of the process, you just want to say to someone, "Okay, we are now in Final Count Down! Start the BDD test!"

If you were to get a person of the street, and start with the Final Count Down, they can follow.  However if you said, "Okay, we are testing the whole process of launching a Rocket, away you go!", they are not going to be able to deliver anything!   

You must always try and remember this!  As very often a BDD feature will start with something that you may have, but someone else doesn't.  I see this all the time in databases.   

Given I Have Item "X"

When I Open Item "X"

Then Cell "Number Times Opened" Is Equal To "5"

If you reran this scenario, would it now fail?   As you opened it once, passed with the number of times opened equalling 5, but rerunning the test, you are now getting the answer "6"!   

It can sometimes be important to prerequisite the database!   Back to our Item X story...

Given I Am Running Against DB 121-2037

This could be instructions to another user, that this feature file will fail if you are not using the same database at the same given point to where you are writing the BDD from.   

©2020 by Agile Testing.