22. Features
Created by: Client / Product
Owner
As an [Actor]
I want [specific System Behavior]
So that I can [have a tangible
benefit]
BDD
Scenarios
Given [a condition exists]
When [an action occurs]
Then [expected result]
23. Feature: User Authentication
As a registered customer
I want to log on the site
So that I can buy some cool stuff
Only custom authentication supported at this stage
If customer has bought during last month show welcome message
If customer hasn’t bought in last month or more, show offers page
Scenario: recent customer logs in
Given customer visits our login page
And customer enters correct username and password
And customer has bought something during last month
Then customer sees “Hi <name>, welcome back!” Message
24. Step definitions
Created by: Developers /
Testers
Feature Scenario
Given [a condition exists]
When [an action occurs]
Then [expected result]
Step Definition
[code that checks condition]
[code that implements action]
[code that tests for expected
result]
BDD
25. Step definitions: User Authentication
Given (/^customer visits our login page$/) do
visit(‘http://our-site.com’)
end
And (/^customer enters correct username and password$/) do
fill_in(usr_name_field, with: ‘fred@gmail.com’
fill_in(password_field, with: ‘password’
end
And (/^customer has bought something during last month$/) do
purchase = Purchases.where(purchase_contact = @user.email)
assert purchase.order_date > Time.now - 1.month
end
And (/^customer sees “Hi <name>, welcome back!” Message$/) do
assert_equal page.has_text?("1 Items found"), true
end
26.
27. Implementation
Created by: Developers
def create
@pid = params[:pid]
@profile = Profile.find_or_create(@pid)
@profile.apply_permissions(current_user)
if params.has_key?(:files)
create_from_upload(params)
elsif params.has_key?(:profile)
add_metadata(params[:profile], "")
end
end
def update
@pid = params[:pid]
redirect_field = ""
if params.has_key?(:redirect_field)
redirect_field = params[:redirect_field]
end
if params.has_key?(:files)
create_from_upload(params)
elsif profile_params
add_metadata(params[:profile], redirect_field)
else
respond_to do |format|
format.html { render action: 'edit' }
format.json { render json: @profile.errors, status:
:unprocessable_entity }
end
end
end
BDD
28.
29.
30. BDD benefits
•Everyone talks the same language
•Expectations are fully understood
•Living documentation
•Measurable progress
•Considerable bug reduction
31. 30% bugs per cycle to 2%
http://www.belatrixsf.com/index.php
/whitepapers-successful-project-
with-behavior-driven-development
BDD benefits: case studies
Zero known defects
http://www.capita-
itps.co.uk/media/127798/BDD-Case-
study-2.pdf
Joke: Newport linguo
Segue: Hands-up: How many here work in small -to medium projects (< £0.5 million) ?
Challenged = missed deadline or failed to deliver full functionality
Segue: Hands-up: How many here work in large projects (> £0.5 million) ?
Segue: So what causes projects to fail?
Not going to repeat causes but they all fall under i) mis-managing requirements, ii) poor communication
If your project fails, itr won’t be because of technical issues
Segue: Hands-up Who is Heisenberg?
Hands-up Not the guy from Breaking Bad
Asserted that certain particles have complementary properties, i.e. when one increases the other one decreases
standard deviation of position x and the standard deviation of momentum p , proportionate to modified Planck constant
Segue: Uncertainty principle exists in software development
standard deviation of quality/functionality q and the standard deviation of time/cost t
Segue: Let’s see how it affects us in development
Segue: Uncertainty principle exists in
Invariably leads to two questions: How much and when?
Segue: We (dev team) have two choices at this point in time
Segue: would like to talk about a 3rd choice, but first we have to talk about scrum
Question: Who knows about Scrum without thinking of rugby?
Explain Scrum. Sprint is the essence here.
Seque: What’s in a sprint?
Seque: Why are Sprints good?
Transparency: client know what and when we’re doing
Predictability: set life-cycle, everyone knows when next devlivery will be
Responsiveness: short life-cycles allow for responding to change in requirements, priorities, etc.
Risk mitigation: Client: can only waste a sprint’s worth of money. Development team: no chance of death-march projects.
Step definitions = Executable specifications
Knowledge acquisition: prototype, compare performance, etc
Technical Work: e.g. “setup a MySQL database”
Need to estimate scenarios. Estimation is a topic on its own, please see my SwanseaCon talk
Because of short, incremental sprint cycles, change can be managed easily.
Sprint has to show something at the end, so inaccurate requrements caught more often.
Cliient is engaged at beginning and end of sprint, so communcation is improved.