introduction to bdd
TRANSCRIPT
![Page 1: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/1.jpg)
Copyright © 2015 SolutionsIQ Inc. All rights reserved.
6801 185th Ave NE, Suite 200Redmond, WA 98052solutionsiq.com1.800.235.4091
Behavior Driven development Introduction
PREPARED BYRanjith TharayilAgile Coach SolutionsIQ
![Page 2: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/2.jpg)
2
Not again , Stop the crap we have seen this
![Page 3: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/3.jpg)
3
History
public class CustomerLookupTest extends TestCase { testFindsCustomerById() { ... } testFailsForDuplicateCustomers() { ... } ...}
renders something like this:
CustomerLookup- finds customer by id- fails for duplicate customers- ...
Dan North
• Thought experiment • AgileDox• Chris Stevenson
![Page 4: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/4.jpg)
4
“ ”BDD is about implementing an application by describing it from the point of view of its stakeholders
![Page 5: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/5.jpg)
5
Title: Customer withdraws cashAs a customer, I want to withdraw cash from an ATM,so that I don’t have to wait in line at the bank.
Scenario 1: Account is in creditGiven the account is in creditAnd the card is validAnd the dispenser contains cashWhen the customer requests cashThen ensure the account is debitedAnd ensure cash is dispensedAnd ensure the card is returned
Scenario 2: Account is overdrawn past the overdraft limitGiven the account is overdrawnAnd the card is validWhen the customer requests cashThen ensure a rejection message is displayedAnd ensure cash is not dispensedAnd ensure the card is returned
![Page 6: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/6.jpg)
6
The Philosophy
Product Owner
Developers Quality Assurance
Production Support
Business
![Page 7: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/7.jpg)
7
Lack of Collaboration
![Page 8: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/8.jpg)
8
The old school of thought , Inside Out
Test
Code
Spec
Inside Out
![Page 9: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/9.jpg)
9
The BDD school of thought ,Outside in
Spec
Test
Code
Outside in
![Page 10: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/10.jpg)
10
BDD pros
• High collaboration
• Early feedback
• Living documentation
• Domain language
• Executable Acceptance criteria
• Enables high Automation
• Enables Disciplined delivery
![Page 11: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/11.jpg)
11
Writing scenarios , Modelling the systems as a state Machine .
Scenario 1: Account is in credit
Given the account is in creditAnd the card is validAnd the dispenser contains cash
When the customer requests cash
Then ensure the account is debitedAnd ensure cash is dispensedAnd ensure the card is returned
Given Then
when
![Page 12: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/12.jpg)
12
let’s imagine you’re building a credit card payment system
Customers should be prevented from entering invalid credit card details.
If a customer enters a credit card number that isn’t exactly 16 digits long, when they try to submit the form, it should be redisplayed with an error message advising them of the correct number of digits.
![Page 13: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/13.jpg)
13
Feature: Withdraw Cash Most customers will use the ATM to make quick withdrawals of cash from their checking or savings accounts. The ATM will only dispense $20 bills.
Scenario: Withdraw money from an account Given my account has a balance of $100 When I withdraw $20 Then $20 will be released by the cash device And my account balance will be $80
Scenario: Amount not a multiple of $20 Given my account has a balance of $100 When I try to withdraw $15 Then I will receive an error that I must specify a multiple of $20
Scenario: Insufficient funds Given my account has a balance of $40 When I try to withdraw $60 Then I will receive an insufficient funds error
![Page 14: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/14.jpg)
14
Feature: Feedback when entering invalid credit card details
Background: Given I have chosen some items to buy And I am about to enter my credit card details
Scenario: Credit card number too short When I enter a card number that's only 15 digits long And all the other details are correct And I submit the form Then the form should be redisplayed And I should see a message advising me of the correct number of digits
Scenario: Expiry date invalid When I enter a card expiry date that's in the past And all the other details are correct And I submit the form Then the form should be redisplayed And I should see a message telling me the expiry date must be wrong
![Page 15: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/15.jpg)
15
Background
![Page 16: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/16.jpg)
16
Background
![Page 17: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/17.jpg)
17
Data Tables
![Page 18: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/18.jpg)
18
Scenario Outline
![Page 19: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/19.jpg)
19
Scenario Outline
![Page 20: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/20.jpg)
20
Testing stack
![Page 21: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/21.jpg)
21
BDD and test Pyramid
I have shamelessly copied this pic form Mike Cohn's book
![Page 22: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/22.jpg)
22
Test iceberg
![Page 23: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/23.jpg)
23
The flow
N-1 N N+1
» Sprints
spec
» Sprint planning
» Pull only those with spec ready » Three Amigo Meetings
» BA ,PO» Developers » QA» Production Support » Any one who could
contribute in scenario identification
• Disciplined delivery• Working agreements • DOR• DOD• Less risk of failure
![Page 24: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/24.jpg)
24
Scenario Identification
Functional:Happy path
Sad path
Constraints
![Page 25: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/25.jpg)
25
Feature injection The aim of Feature Injection is to flesh out the minimum set of features that will provide
the most benefit to stakeholders in terms of achieving their business goals
1. Hunt the value.2. Inject the features.3. Spot the examples
![Page 26: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/26.jpg)
26
When to Embrace BDD ?
The problem
• Full team participation
• ROI
• waste of time
“Assumption BDD is practices in its fullest of its sprits” and still there is question on ROI
Abstract : Behaviour Driven Development (BDD) is a collaborative and disciplined technique to help us build
the right product. In the last decade BDD has had her own bit of glory and criticism. Many teams in the recent
past have reaped benefits from this technical practice, while some teams complain that are yet to find any
value. This article focuses on answering two questions; Why BDD might not always be the right choice? What
are the ideal conditions when teams should adopt it?
![Page 27: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/27.jpg)
27
The Gap
![Page 28: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/28.jpg)
28
Complexity
![Page 29: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/29.jpg)
29
When to use Behaviour Driven Development
![Page 30: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/30.jpg)
30
How to measure complexity
Points Complexity Description
1 Just about everyone in the world has done this
2 Lots of people have done this, including someone on our team.
3 Someone in our company has done this, or we have access to expertise
4 Someone in the world did this, but not in our organization (and probably
at a competitor)
5 Nobody in the world has ever done this before
Second Order ignorance We say second order of ignorance exist if “when I don't know that I don't know something”.
Liz Keogh
![Page 31: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/31.jpg)
31
BDD for maintenance projects ?
• Lots of legacy code • Enhancements
• Defect fix
• Production issues
![Page 32: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/32.jpg)
Adapting BDD for software maintenance projects using the “dEep” model.
we can categories the type of work into 4 different types .
32
d , defects
E ,Complex Enhancement
e ,Simple Enhancements
p , urgent production issues
![Page 33: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/33.jpg)
33
E , Complex Enhancements
• classical BDD style:
• 3 Amigo meetings
• specification by example
• pull based
• TDD strategy , etc
• working agreements ,DOR ,DOD
• highly disciplined
• Full team participation
![Page 34: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/34.jpg)
34
e ,Smaller Enhancements
• Skip 3 Amigo meetings
• cover the module with scenarios based test
• Express new requirements in the form of a scenario
• get the spec reviewed by BA/PO , dev ,QA .
• Highly pragmatic approach ,
• (need basis ) UT or E2E test
• test first approach or TDD
![Page 35: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/35.jpg)
35
d, Defects
• d came to existence because there was a hole in your test pyramid
• fix the hole that caused the issue ,may be a test or two , be pragmatic
• fix the code , again test first strategy
![Page 36: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/36.jpg)
36
p, urgent production issues
• fix the code first & deploy
• put a card in your back log to fix the hole in test pyramid which caused the issues
• Test last strategy
![Page 37: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/37.jpg)
37
BDD in a nut shell
I have shamelessly copied this pic from Rachel's
blog
![Page 38: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/38.jpg)
38
Key Question
I have shamelessly copied this pic from Naresh Jain PPT
![Page 39: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/39.jpg)
“
”
BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters.
![Page 40: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/40.jpg)
40
“BDD doesn't come with BRAINS kindly use yours”
![Page 41: Introduction to BDD](https://reader031.vdocuments.mx/reader031/viewer/2022012322/58a4573c1a28ab55068b62e3/html5/thumbnails/41.jpg)
41
Thank you!solutionsiq.com / 1.800.235.4091
» Acknowledgments :» Sharad Julka for proposing the catchy name “dEep”
» Images in this document are shameless coped from 2 books » BDD in Action ,Manning » The Cucumber Book