[role], I want [goal/desire] so that [benefit]
Some examples of user stories can be:
As a debit card holder, I want to withdraw cash from ATM so that I don’t have to go to the bank.
As a student, I want to login to the college website so that I can view the exam’s result.
Once we have a user story, we try to identify the scenarios that cover the story. This is the part where a lot of group discussion takes place between stakeholders, testers, developers and QA people. They try to come up with concise and limited scenarios for the acceptance of the user story. If all the scenarios decided here are implemented, then the user story is formally completed.
The scenarios are written in the following format
Given [initial context], when [event occurs], then [ensure some outcomes]
Some examples of scenarios can be as follows:
Given a valid pin, when the card holder enquires balance, then he should be displayed his available balance.
Given an Invalid pin, when the card holder tries to access the options menu, then he should be displayed the message “Invalid pin, Please re-enter your pin.”
From the above examples you can see that we are defining the behavior of how an ATM will work but there are tech words there. The primary focus is on how the system (ATM in this case) will behave.
You can see from the above examples that it would be very easy for a developer to implement the above behavior and verify it. Once you have verified by the aid of unit tests that your system is meeting all the scenarios then you can mark the user story complete and move on. BDD is more effective and productive because it involved all the stake holders and all of them unanimously decide when a user story or feature is done, there are no chances of ifs and buts if you go along the path of BDD
If you are completely new to TDD then I strongly suggest you to go with BDD right from the word go. You really don’t need to worry about any tools just try to write tests that actually test behaviors. Once you get the hang of it, you can certainly start using some of the tools that help you automate your work and make you more efficient.
I will try to cover my personal toolset that I use to do BDD. Till then happy Behavior Driving