Upload
naresh-jain
View
4.261
Download
2
Embed Size (px)
DESCRIPTION
The BDD Workshop offers a comprehensive, hands-on introduction to behavior driven development via an interactive-demo. Over the past decade, eXtreme Programming practices like Test-Driven Development (TDD) and Behaviour Driven Development (BDD) have fundamentally changed software development processes and inherently how engineers work. Practitioners claim that it has helped them significantly improve their collaboration with business, development speed, design & code quality and responsiveness to changing requirements. Software professionals across the board, from Internet startups to medical device companies to space research organizations, today have embraced these practices. This workshop explores the foundations of TDD & BDD with the help of various patterns, strategies, tools and techniques.
Citation preview
Copyright © 2013, AgileFAQs. All Rights Reserved.
Behavior Driven Development
Naresh [email protected]
@nashjain http://nareshjain.com
Copyright © 2013, AgileFAQs. All Rights Reserved.
Pick one scenario and in relation to your scenario, what are the specific observable results that will tell you that the activity has been successfully completed?
Going out for Movie (THX sound and Digital projection)
Going out for meal (one veg.)
Going shopping ($50)[5 Minutes]
Present back to the group your findings. [3 minutes per group]
Warmup Scenarios
Commercial Break!
Copyright © 2013, AgileFAQs. All Rights Reserved.
Tech Talks!
Elevator Pitch
Business Goals
Chartering
PragmaticPersonas
User Goals
Day in Life of each Persona
Scenarios &
Narratives
Personas
Activity Map
Task MapInteraction DesignUI Sketch
Story Mapping
PrioritizationGrouping by ThemesReiterating
Planning
User Stories
AcceptanceCriteria
User Story Authoring
Product Discovery -‐ Overview
Vision
Goal
Capability
Feature
Story
Scenario
Code
Elevator Pitch
Business Goals
Chartering
PragmaticPersonas
User Goals
Day in Life of each Persona
Scenarios & Narratives
Personas
Activity Map
Task MapInteraction DesignUI Sketch
Story Mapping
PrioritizationGrouping by ThemesReiterating
Planning
User StoriesAcceptanceCriteria
User Story Authoring
Copyright © 2013, AgileFAQs. All Rights Reserved.
What are we really trying to build?
User Stories
Copyright © 2013, AgileFAQs. All Rights Reserved.
Story is a smallest piece of functionality that add business value
Stories should follow Ron Jeffries’ 3 Cs
Card – Placeholder for conversation
Conversation – Actual discussion between dev team and user
Confirmation – Acceptance criteria to determine when the story is finished
What is a Story?
Copyright © 2013, AgileFAQs. All Rights Reserved.
In order to... <user goal/business justification>
As a .. <user who requires this feature>
I need .. <do something>
Typical Story Format
Story Title - Actor Action Context
Copyright © 2013, AgileFAQs. All Rights Reserved.
Title: Keen Reader subscribes to a blog
In order to stay up-to-date with new posts
As a keen reader of your blog
I need to subscribe to your blog
Story Example
Copyright © 2013, AgileFAQs. All Rights Reserved.
Title: Social Networking Enthusiast uploads profile picture
In order for my friends to see how I look and recognize me
As a Social Networking Enthusiast
I need to upload my profile picture
Another Story Example
Copyright © 2013, AgileFAQs. All Rights Reserved.
As a ____, I want to be able to ____ so
that ____
Product Backlog
Might have an initial estimate (perhaps for both analysis and development),
and an expression of technical and business
confidence that this is real and achievable
As a ____, I want to be able to ____ so
that ____
I will know this is done when _______
Release Backlog
More detailed estimate, and a specific acceptance test – low confidence stories might
be “spiked” or prototyped
As a ____, I want to be able to ____ so
that ____
I will know this is done when _______
To do this I must:1) _____2) _____
Sprint Backlog
Possible automation of the acceptance
test
Development team breaks out the detail of work
needed to pass test
Release planning Iteration planning
Business Goals
Inception
Stories are fundamental unit of activity
User Goals
Copyright © 2013, AgileFAQs. All Rights Reserved.
Stories should follow the INVEST principle:
Independent
Negotiable
Valuable
Estimateable
Small
Testable
What makes a good Story?
Copyright © 2013, AgileFAQs. All Rights Reserved.
ScenariosAcceptance Criteria
Copyright © 2013, AgileFAQs. All Rights Reserved.
Is a set of conditions that the Story must meet for it to be accepted as complete
Is typically provided by the customer or product owner.
Is not a replacement for conversation.
Is the results of the conversation
Scenarios are NOT tests
Scenario
Copyright © 2013, AgileFAQs. All Rights Reserved.
Scenario should contain:
ACTOR
VERB – DESCRIBING A BEHAVIOR
OBSERVABLE RESULT
To accommodate pre-conditions scenarios can be expressed as
Given [Precondition]
When [Actor + Action]
Then [Observable Result]
Writing Scenarios
Copyright © 2013, AgileFAQs. All Rights Reserved.
Example
Given the user has a valid facebook account and a digital picture on her computer,
When she uploads a picture in facebook,
Then her the picture should be visible to all her friends in her network.
Given an user is trying to find a friend on facebook,
When the user searches for a person using their name,
Then their profile picture should be displayed along with other details.
In order to keep facebook's reputation intact and stay out of legal hassles
As owner of facebook,
I need users to upload authentic, personal profile picture
Social Networking Enthusiast uploads profile picture
Copyright © 2013, AgileFAQs. All Rights Reserved.
Cucumber Style BDDFeature: Login In order to access secure content As a registered user I need to authenticate myself Scenario: Login with valid credentials Given I am not logged in When I try to login with "test" and "secret" Then I should be logged in Scenario: Login with invalid credentials Given I am not logged in When I try to login with "test" and "wrongpassword" Then I should not be logged in And I should be shown error message "Invalid username or password"
Copyright © 2013, AgileFAQs. All Rights Reserved.
Step Definition
Given /^I am not logged in$/ do browser.navigate_to("http://your_url.com")end
When /^I try to login with "([^\"]*)" and "([^\"]*)"$/ do |username, password| browser.textbox("user").value = username browser.password("password").value = password browser.submit("Login").clickend
Then /^I should be logged in$/ do if !browser.button("Logout").exists? raise "Not logged in" endend
Then /^I should be shown error message "([^\"]*)"$/ do |msg| value = browser.div("errorMessage").text if value != msg raise "Incorrect message: #{value}" endend
Then /^I should not be logged in$/ do if !browser.submit("Login").exists? raise "Logged in" endend
Copyright © 2013, AgileFAQs. All Rights Reserved.
Acceptance TestsAcceptance Criteria & Tests: Definition
Acceptance Criteria
Examples (data + scenarios)
Acceptance Tests
+
Copyright © 2013, AgileFAQs. All Rights Reserved.
Scenarios =
Executable Tests
Copyright © 2013, AgileFAQs. All Rights Reserved.
Tasks
To accomplish this story:
we start off with a simple upload and image display
restrict user to only upload certain image types (gif, jpg and png)
figure out where to store the image. (performant and fault-tolerant)
scale down (size, resolution, etc.) of the image
and so on...
Team members further break down each story into tasks that needto be completed to meet the acceptance criteria for the story.
Copyright © 2013, AgileFAQs. All Rights Reserved.
Demo
Copyright © 2013, AgileFAQs. All Rights Reserved.
BDD
Copyright © 2013, AgileFAQs. All Rights Reserved.
Key Questions
Are we building the right product?
Are we building the product right?
Business Facing
Technology/Implementation Facing
Copyright © 2013, AgileFAQs. All Rights Reserved.
Brian Marick’s Test Categorization
Business Facing
Technology/Implementation Facing
Supp
orts
Pro
gram
min
gC
ritique product
Copyright © 2013, AgileFAQs. All Rights Reserved.
It Helps to Think of Tests this way...
Business Facing
Technology/Implementation Facing
Dri
ves
Dev
elop
men
t Critique productUnit Testing
Acceptance Testing Low-fi prototypes
Exploratory TestingUI and Usability Testing
Performance TestingSystem Tests
Copyright © 2013, AgileFAQs. All Rights Reserved.
Inverting the Testing Pyramid
Unit Tests
IntegrationTests
End-to-EndGUI Tests 80-90%
5-15%
1-5%
Typical testing strategies lead to an inverted testing pyramid...
Manual Checking
Copyright © 2013, AgileFAQs. All Rights Reserved.
Inverting the Testing Pyramid
Unit Tests
Biz Logic Acceptance Tests
Integration Test
Workflow Tests
End to End Flow Tests
GUITests
1%
70%
10%
9%
6%
4%
PerformanceTests
SecurityTests
This is the need of the hours...
One Layer Below GUI
Copyright © 2013, AgileFAQs. All Rights Reserved.
TDD Rhythm - Test, Code, Refactor
Add a Test
Run the Test
Make a little change
Run the Test
Refactor
Fail
Pass
Fail
Pass
Test Driven Development
Copyright © 2013, AgileFAQs. All Rights Reserved.
Behavior Driven Development
Iteration
Automated Acceptance Tests
AutomatedAcceptance Tests
Story
Scenario
Scenario
ExploratoryTesting
Automated UI Tests
TESTS
PERFORMENCE
Automated Unit Test
Copyright © 2013, AgileFAQs. All Rights Reserved.
Benefits of BDD
Copyright © 2013, AgileFAQs. All Rights Reserved.
Why?
Copyright © 2013, AgileFAQs. All Rights Reserved.
Better Commitment and Buy-inFocus on Business Value
Copyright © 2013, AgileFAQs. All Rights Reserved.
Ubiquitous Domain Language
Copyright © 2013, AgileFAQs. All Rights Reserved.
Right focus
Copyright © 2013, AgileFAQs. All Rights Reserved.
Evolutionary Design
Copyright © 2013, AgileFAQs. All Rights Reserved.
Breaking the Knowledge Silos in Distributed Team
Copyright © 2013, AgileFAQs. All Rights Reserved.
Greater ROI
Copyright © 2013, AgileFAQs. All Rights Reserved.
Predictability & Confidence