What is Behavior Driven Development?
Behavior Driven Development (BDD)
is well known practice for collaboration and many organizations practice it to
bridge gap between in product management and software development team.
BDD help in describing
requirement in the form of feature file and scenarios. Scenarios further get
describe in format of Given, When and Then. The language that mainly used in
writing feature file is called is Gherkin. Gherkin language can be used to
write feature file in more than 40 languages. Some of the important keywords of
Gherkin mentioned below that will help in describing features and scenarios:-
Feature, Scenario, Given, When,
Then, And, But, Background, Scenario Outline and Examples
How to write Feature
file?
You can write feature file in notepad as well so basically
there is no need to know any particular tools and below is format.
Feature:
Search Flight
As a flyer I want to search
available flight between Bangalore and Chennai So that I can book to travel on
given date.
#above story/description is optional
Scenario:
Search all available flight based on date, origin and destination
Given
flyer enter travel date as “12/12/2016” and origin as “Bangalore and
Destination as “Chennai”
When
Click on Search button
Then
search page should show all available flight
And
option to book flight
When to write feature
file?
If you are practicing Scrum then
better to have it during product backlog refinement session else make it mandatory
for requirement gathering.
What is complex story/requirement?
Take above example of flight
search, this looks very simple but can it be deliver in 2 weeks of sprint? May
not possible if you have to complete all work that has been mentioned in
Definition of Done (DoD)? So how to slice it to have shippable product at the
end of sprint?
Use BDD scenario like below to
slice it. Now change scenario to search flights only for one airlines at time
because connecting multiple sources may not be possible in one sprint and
modify it like below.
Scenario:
Search only Indigo flight based on date, origin and destination
Given
flyer enter travel date as “12/12/2016” and origin as “Bangalore and
Destination as “Chennai”
When
Click on Search button
Then
search page should show all available flight
And
option to book flight
Scenario: Search only Spicejet flight based on date, origin and destination
Given flyer enter travel date as “12/12/2016” and origin as “Bangalore
and Destination as “Chennai”
When Click on Search button
Then search page should show all available flight
And option to book flight
Scenario:
Search only Jet Airways flight based on date, origin and destination
Given
flyer enter travel date as “12/12/2016” and origin as “Bangalore and
Destination as “Chennai”
When
Click on Search button
Then
search page should show all available flight
And
option to book flight
Now team can decide to build only
those scenario that can be delivered within one sprint and rest scenarios in
upcoming sprints.
Above scenarios can also be further sliced like below if
needed.
Scenario: One way flight of Indigo
Scenario: Return flight of Indigo
Scenario: Multiple location search
for Indigo etc.
Leanpitch provides the best scrum and agile training. We are leading provider of Certified Scrum Master (CSM), Certified Scrum Product Owner (CSPO), Certified Scrum Developer (CSD), Kanban , Test Driven Development (TDD), Behavior Driven Development (BDD) in Bangalore, Chennai, Mumbai, Pune, Delhi and Hyderabad. Visit our website to know more about
Leanpitch Offering.