SlideShare a Scribd company logo
1 of 46
Download to read offline
Matt Daubert
MeYou Health
@mdaubs83
TDD is about code design
“It’s harder to read code
than to write it.”
- Joel Spolsky
“Agile processes
harness change”
- 2nd Principle, Agile Manifesto
“No matter how slow you
are writing clean code, you
will always be slower if you
make a mess.”
- Uncle Bob Martin
TDD does not address...
Which test do I need to
write next?
Starting point.
How do I know when I’ve
written the last test?
Definition of done.
How does this new code
add value for the user?
Am I writing the right code?
Scenario
BDD

Unit test

TDD

Refactor

Code to
pass test
“If you can’t explain it
simply, you don’t
understand it well
enough.”
- Albert Einstein
Developing
acceptance
tests

Implementing
acceptance
tests
Successful products provide
value to users.
Users derive value by interacting with
products.
Interactions are testable.
Two sides to every (user) story
Narrative

Acceptance Criteria

- User/persona/role

- Multiple concrete
examples describing how
the feature works

- Goal or value the user
would like to achieve
- The interaction the user
should have with the
product in order to achieve
their goal and gain value
Our goals, user goals

Specification

Acceptance Test

Living Documentation

increasing

Domain Language

Key Examples

Shared Understanding

Scope
Ain't Nobody Got Time For That
Refining User Stories
- Stories are refined through collaboration
- Stories may divide if they get complex
- Stories will often start with a small number
of key examples and expand as shared
understanding develops
- Refinement is complete when a story passes
the "INVEST" test.
INVEST in User Stories
INVEST in User Stories
Independent
Can be scheduled and re-prioritized with minimal risk of being blocked.
INVEST in User Stories
Independent
Negotiable
Can be changed or discarded if business, market, or technical needs require.
INVEST in User Stories
Independent
Negotiable
Valuable
Stories that don't add value for users will never see a return on investment.
INVEST in User Stories
Independent
Negotiable
Valuable
Estimable
A reasonable idea of effort required to complete is needed to pace the sprint.
INVEST in User Stories
Independent
Negotiable
Valuable
Estimable
Small
Quicker to implement, minimize risk, get feedback sooner.
INVEST in User Stories
Independent
Negotiable
Valuable
Estimable
Small
Testable
A story isn't considered done until its acceptance tests pass.
What is an acceptance test?
● Executable version of a refined user story
● Written in domain language
● Scenarios validate story acceptance criteria
● Defines start and finish lines
● Documents value proposition
● Respects "Three Levels of Description"
Three Levels of Description
Business Rule
What is the scenario demonstrating?

Scenario: Free delivery is offered to
customers who order two or more books
Three Levels of Description
Business Rule
What is the scenario demonstrating?

User Workflow
How can a user exercise the functionality?
Given I put two books in my cart
When I checkout
Then I should be able to select free delivery
Three Levels of Description
Business Rule
What is the scenario demonstrating?

User Workflow
How can a user exercise the functionality?

Technical Activity
What are the technical steps required to exercise each workflow step?
step 'I checkout' do
click_on 'Checkout'
end
Protips
(Lightning Round)
Disambiguate w/Concrete Examples
Scenario Outline: Users cannot sign in after the sixth failed sign in attempt over a one
day period
Given I have failed to sign in <yesterday> times yesterday
And I have failed to sign in <today> times today
Then I should be <result> to sign in

Examples:
| yesterday | today | result |
| 0

| 0

| able

|

| 0

| 5

| able

|

| 0

| 6

| unable |

| 5

| 0

| able

|

| 5

| 5

| able

|

| 5

| 6

| unable |

| 6

| 0

| able

|

| 6

| 5

| able

|

| 6

| 6

| unable |
Gherkin Protip: Hide Implementation
Scenario: Selected customers are notified of a flash sale
Given I am a store manager
When I create a flash sale for VIP customers that starts
tomorrow
And it’s tomorrow
And Resque jobs are run
Then VIP customers receive a Flashmail
Gherkin Protip: Hide Implementation
Scenario: Selected customers are notified of a flash sale
Given I am a store manager
When I create a flash sale for VIP customers
Then VIP customers receive a Flashmail the day of the
flash
Gherkin Protip: Don’t Write Scripts
As a party planner with BFFs
In order to have the best party ever
I want to invite as many BFFs as possible
Given there is a user named Alice
And there is a user named Bob who is BFFs with Alice
And there is a user named Charlie who is BFFs with Bob
When Alice invites Bob to a party
But Alice does not invite Charlie to the same party
Then Alice receives a message
"Do you also want to invite Charlie?"
Gherkin Protip: Don’t Write Scripts
As a party planner with BFFs
In order to have the best party ever
I want to invite as many BFFs as possible
Given I am planning a party
When I invite my BFF Bob
Then I am asked if I might want to invite his BFF Charlie
Gherkin Protip:
Be skeptical of "I should see" steps
Is the act of seeing the thing valuable to the user or is it
an implementation detail?

Yes
Then I should see that the patron has overdue books

No
Then I should see the overdue book icon
Gherkin Protips:
Be skeptical of "And" and “But” keywords
Are these steps really one step?
Are these steps not focused on the feature?
Is this feature really two features?

Be skeptical of "and" and "or" in steps
Is this step really two steps?
Is this scenario really two scenarios?
Gherkin Protips:
Don't test every case
Add examples to disambiguate around edge cases

Never use generic steps to DRY tests
DRY Ruby code behind the steps

Listen when your Gherkin fights you
Can you explain the feature in simple terms?
Use ctags - Never Grep for Steps
● Open a .feature file
● Move cursor to a scenario step
● Press Ctrl+] to open the step definition
● Press Ctrl+t to go back to the .feature file
Step Definitions
# Gherkin
When I sign up with "email@example.com" and "password"
# Cucumber step definition
When /^I sign up (?:with|as) "(.*)" and "(.*)"$/ do |email, pw|
# More Ruby code here
end
# Turnip step definition
step "I sign up with/as :email and :password" do |email, pw|
# More Ruby code here
end
Use Custom Placeholders
step "there are :count monsters" do |count|
count.times { Monster.new(name) }
end
placeholder :count do
match /d+/, &:to_i # { |count| count.to_i }
match /no/ { 0 }
end
(or use Step Argument Transforms in Cucumber)
Use Helper Methods
module MyAccountSteps
step 'I am modifying my AwesomeApp account' do
sign_in @user = create(:user)
select_from_user_drop_down 'My account'
end
end
Organize Your Suite
spec
|- acceptance
|- features
|- encouragement.feature
|- macros
|- session_macros.rb
|- steps
|- encouragement_steps.rb
Every product and team is
different, optimize for yours.
Thanks!

Matt Daubert
MeYou Health
@mdaubs83
Learn from smart people
http://alindeman.github.io/acceptance_testing
http://blog.carbonfive.com/2012/02/14/beginning-outside-in-rails-developmentwith-cucumber-and-rspec/
http://en.wikipedia.org/wiki/INVEST_(mnemonic)
http://specificationbyexample.com/
http://janetgregory.blogspot.com/2010/08/atdd-vs-bdd-vs-specification-byexample.html
http://www.drdobbs.com/tdd-is-about-design-not-testing/229218691

More Related Content

What's hot

Async Code Reviews Are Killing Your Company’s Throughput - Dragan Stepanović
Async Code Reviews Are Killing Your Company’s Throughput - Dragan StepanovićAsync Code Reviews Are Killing Your Company’s Throughput - Dragan Stepanović
Async Code Reviews Are Killing Your Company’s Throughput - Dragan StepanovićDragan Stepanović
 
Behat - human-readable automated testing
Behat - human-readable automated testingBehat - human-readable automated testing
Behat - human-readable automated testingnyccamp
 
User stories primer - how to think differently about constructing stories
User stories primer - how to think differently about constructing storiesUser stories primer - how to think differently about constructing stories
User stories primer - how to think differently about constructing storiesDave Ungar
 
Async Code Reviews Are Killing Your Company’s Throughput - [Old]
Async Code Reviews Are Killing Your Company’s Throughput - [Old]Async Code Reviews Are Killing Your Company’s Throughput - [Old]
Async Code Reviews Are Killing Your Company’s Throughput - [Old]Dragan Stepanović
 
Language portfolio
Language portfolioLanguage portfolio
Language portfolioDhaval Dalal
 
Geecon10: Object Oriented for nonbelievers
Geecon10: Object Oriented for nonbelieversGeecon10: Object Oriented for nonbelievers
Geecon10: Object Oriented for nonbelieversBruno Bossola
 
PuppetConf 2017: Config Mgmt Architect: The Unauthorized Instruction Manual *...
PuppetConf 2017: Config Mgmt Architect: The Unauthorized Instruction Manual *...PuppetConf 2017: Config Mgmt Architect: The Unauthorized Instruction Manual *...
PuppetConf 2017: Config Mgmt Architect: The Unauthorized Instruction Manual *...Puppet
 
Readable Tests Using BDD
Readable Tests Using BDDReadable Tests Using BDD
Readable Tests Using BDDFurqan Khan
 

What's hot (9)

Async Code Reviews Are Killing Your Company’s Throughput - Dragan Stepanović
Async Code Reviews Are Killing Your Company’s Throughput - Dragan StepanovićAsync Code Reviews Are Killing Your Company’s Throughput - Dragan Stepanović
Async Code Reviews Are Killing Your Company’s Throughput - Dragan Stepanović
 
Behat - human-readable automated testing
Behat - human-readable automated testingBehat - human-readable automated testing
Behat - human-readable automated testing
 
User stories primer - how to think differently about constructing stories
User stories primer - how to think differently about constructing storiesUser stories primer - how to think differently about constructing stories
User stories primer - how to think differently about constructing stories
 
Async Code Reviews Are Killing Your Company’s Throughput - [Old]
Async Code Reviews Are Killing Your Company’s Throughput - [Old]Async Code Reviews Are Killing Your Company’s Throughput - [Old]
Async Code Reviews Are Killing Your Company’s Throughput - [Old]
 
Testing Content
Testing ContentTesting Content
Testing Content
 
Language portfolio
Language portfolioLanguage portfolio
Language portfolio
 
Geecon10: Object Oriented for nonbelievers
Geecon10: Object Oriented for nonbelieversGeecon10: Object Oriented for nonbelievers
Geecon10: Object Oriented for nonbelievers
 
PuppetConf 2017: Config Mgmt Architect: The Unauthorized Instruction Manual *...
PuppetConf 2017: Config Mgmt Architect: The Unauthorized Instruction Manual *...PuppetConf 2017: Config Mgmt Architect: The Unauthorized Instruction Manual *...
PuppetConf 2017: Config Mgmt Architect: The Unauthorized Instruction Manual *...
 
Readable Tests Using BDD
Readable Tests Using BDDReadable Tests Using BDD
Readable Tests Using BDD
 

Similar to Why BDD is our BFF

Xp 2016 superchargeyourproductbacklogwithuserstories-suzannelaz
Xp 2016 superchargeyourproductbacklogwithuserstories-suzannelazXp 2016 superchargeyourproductbacklogwithuserstories-suzannelaz
Xp 2016 superchargeyourproductbacklogwithuserstories-suzannelazLaz Allen
 
How getting your hands dirty with code makes you a better business leader @ V...
How getting your hands dirty with code makes you a better business leader @ V...How getting your hands dirty with code makes you a better business leader @ V...
How getting your hands dirty with code makes you a better business leader @ V...Linde Vloeberghs
 
How getting your hands dirty with code makes you a better business leader @ V...
How getting your hands dirty with code makes you a better business leader @ V...How getting your hands dirty with code makes you a better business leader @ V...
How getting your hands dirty with code makes you a better business leader @ V...Hifluence
 
Build the Right Product with Lean UX
Build the Right Product with Lean UXBuild the Right Product with Lean UX
Build the Right Product with Lean UXMike Long
 
It's Not Just About Code
It's Not Just About CodeIt's Not Just About Code
It's Not Just About CodeDan Pickett
 
Rapid Product Development
Rapid Product DevelopmentRapid Product Development
Rapid Product DevelopmentZachary Beer
 
Product design for Non Designers - Montreal Digital Nomad Meetup
Product design for Non Designers - Montreal Digital Nomad MeetupProduct design for Non Designers - Montreal Digital Nomad Meetup
Product design for Non Designers - Montreal Digital Nomad MeetupSebastian Tory-Pratt
 
How to Foster Engagement and Understanding Using Agile
How to Foster Engagement and Understanding Using AgileHow to Foster Engagement and Understanding Using Agile
How to Foster Engagement and Understanding Using AgileSalesforce Admins
 
How to Avoid Common Mistakes in Product by Cake Product Manager
How to Avoid Common Mistakes in Product by Cake Product ManagerHow to Avoid Common Mistakes in Product by Cake Product Manager
How to Avoid Common Mistakes in Product by Cake Product ManagerProduct School
 
Expanding skill sets - Broaden your perspective on design
Expanding skill sets - Broaden your perspective on designExpanding skill sets - Broaden your perspective on design
Expanding skill sets - Broaden your perspective on designroskakori
 
The Best A/B Test Idea You Haven’t Thought Of
The Best A/B Test Idea You Haven’t Thought OfThe Best A/B Test Idea You Haven’t Thought Of
The Best A/B Test Idea You Haven’t Thought OfKissmetrics on SlideShare
 
User Story Splitting.pptx
User Story Splitting.pptxUser Story Splitting.pptx
User Story Splitting.pptxPaul Boos
 
Rapid Prototyping & Customer Development
Rapid Prototyping & Customer DevelopmentRapid Prototyping & Customer Development
Rapid Prototyping & Customer Developmentjohnwlong
 
User story driven product development process
User story driven product development processUser story driven product development process
User story driven product development processRan Liron
 
Develop a good product - 3 phases 3 methodologies - detail
Develop a good product - 3 phases 3 methodologies - detailDevelop a good product - 3 phases 3 methodologies - detail
Develop a good product - 3 phases 3 methodologies - detailJean-François Nguyen
 
The Whole Story of The User Story
The Whole Story of The User StoryThe Whole Story of The User Story
The Whole Story of The User StoryXPDays
 
User Story Mapping
User Story MappingUser Story Mapping
User Story MappingStefano Leli
 
DevDay 2013 - Building Startups and Minimum Viable Products
DevDay 2013 - Building Startups and Minimum Viable ProductsDevDay 2013 - Building Startups and Minimum Viable Products
DevDay 2013 - Building Startups and Minimum Viable ProductsBen Hall
 
Continuous business goal validation
Continuous business goal validationContinuous business goal validation
Continuous business goal validationHylke Stapersma
 
Alexey klochay and "Wizard on Demand"
Alexey klochay and "Wizard on Demand"Alexey klochay and "Wizard on Demand"
Alexey klochay and "Wizard on Demand"OneCoWork
 

Similar to Why BDD is our BFF (20)

Xp 2016 superchargeyourproductbacklogwithuserstories-suzannelaz
Xp 2016 superchargeyourproductbacklogwithuserstories-suzannelazXp 2016 superchargeyourproductbacklogwithuserstories-suzannelaz
Xp 2016 superchargeyourproductbacklogwithuserstories-suzannelaz
 
How getting your hands dirty with code makes you a better business leader @ V...
How getting your hands dirty with code makes you a better business leader @ V...How getting your hands dirty with code makes you a better business leader @ V...
How getting your hands dirty with code makes you a better business leader @ V...
 
How getting your hands dirty with code makes you a better business leader @ V...
How getting your hands dirty with code makes you a better business leader @ V...How getting your hands dirty with code makes you a better business leader @ V...
How getting your hands dirty with code makes you a better business leader @ V...
 
Build the Right Product with Lean UX
Build the Right Product with Lean UXBuild the Right Product with Lean UX
Build the Right Product with Lean UX
 
It's Not Just About Code
It's Not Just About CodeIt's Not Just About Code
It's Not Just About Code
 
Rapid Product Development
Rapid Product DevelopmentRapid Product Development
Rapid Product Development
 
Product design for Non Designers - Montreal Digital Nomad Meetup
Product design for Non Designers - Montreal Digital Nomad MeetupProduct design for Non Designers - Montreal Digital Nomad Meetup
Product design for Non Designers - Montreal Digital Nomad Meetup
 
How to Foster Engagement and Understanding Using Agile
How to Foster Engagement and Understanding Using AgileHow to Foster Engagement and Understanding Using Agile
How to Foster Engagement and Understanding Using Agile
 
How to Avoid Common Mistakes in Product by Cake Product Manager
How to Avoid Common Mistakes in Product by Cake Product ManagerHow to Avoid Common Mistakes in Product by Cake Product Manager
How to Avoid Common Mistakes in Product by Cake Product Manager
 
Expanding skill sets - Broaden your perspective on design
Expanding skill sets - Broaden your perspective on designExpanding skill sets - Broaden your perspective on design
Expanding skill sets - Broaden your perspective on design
 
The Best A/B Test Idea You Haven’t Thought Of
The Best A/B Test Idea You Haven’t Thought OfThe Best A/B Test Idea You Haven’t Thought Of
The Best A/B Test Idea You Haven’t Thought Of
 
User Story Splitting.pptx
User Story Splitting.pptxUser Story Splitting.pptx
User Story Splitting.pptx
 
Rapid Prototyping & Customer Development
Rapid Prototyping & Customer DevelopmentRapid Prototyping & Customer Development
Rapid Prototyping & Customer Development
 
User story driven product development process
User story driven product development processUser story driven product development process
User story driven product development process
 
Develop a good product - 3 phases 3 methodologies - detail
Develop a good product - 3 phases 3 methodologies - detailDevelop a good product - 3 phases 3 methodologies - detail
Develop a good product - 3 phases 3 methodologies - detail
 
The Whole Story of The User Story
The Whole Story of The User StoryThe Whole Story of The User Story
The Whole Story of The User Story
 
User Story Mapping
User Story MappingUser Story Mapping
User Story Mapping
 
DevDay 2013 - Building Startups and Minimum Viable Products
DevDay 2013 - Building Startups and Minimum Viable ProductsDevDay 2013 - Building Startups and Minimum Viable Products
DevDay 2013 - Building Startups and Minimum Viable Products
 
Continuous business goal validation
Continuous business goal validationContinuous business goal validation
Continuous business goal validation
 
Alexey klochay and "Wizard on Demand"
Alexey klochay and "Wizard on Demand"Alexey klochay and "Wizard on Demand"
Alexey klochay and "Wizard on Demand"
 

Recently uploaded

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Why BDD is our BFF

  • 2. TDD is about code design
  • 3. “It’s harder to read code than to write it.” - Joel Spolsky
  • 4. “Agile processes harness change” - 2nd Principle, Agile Manifesto
  • 5. “No matter how slow you are writing clean code, you will always be slower if you make a mess.” - Uncle Bob Martin
  • 6. TDD does not address...
  • 7. Which test do I need to write next? Starting point.
  • 8. How do I know when I’ve written the last test? Definition of done.
  • 9. How does this new code add value for the user? Am I writing the right code?
  • 11. “If you can’t explain it simply, you don’t understand it well enough.” - Albert Einstein
  • 13. Successful products provide value to users. Users derive value by interacting with products. Interactions are testable.
  • 14. Two sides to every (user) story Narrative Acceptance Criteria - User/persona/role - Multiple concrete examples describing how the feature works - Goal or value the user would like to achieve - The interaction the user should have with the product in order to achieve their goal and gain value
  • 15. Our goals, user goals Specification Acceptance Test Living Documentation increasing Domain Language Key Examples Shared Understanding Scope
  • 16. Ain't Nobody Got Time For That
  • 17.
  • 18. Refining User Stories - Stories are refined through collaboration - Stories may divide if they get complex - Stories will often start with a small number of key examples and expand as shared understanding develops - Refinement is complete when a story passes the "INVEST" test.
  • 19. INVEST in User Stories
  • 20. INVEST in User Stories Independent Can be scheduled and re-prioritized with minimal risk of being blocked.
  • 21. INVEST in User Stories Independent Negotiable Can be changed or discarded if business, market, or technical needs require.
  • 22. INVEST in User Stories Independent Negotiable Valuable Stories that don't add value for users will never see a return on investment.
  • 23. INVEST in User Stories Independent Negotiable Valuable Estimable A reasonable idea of effort required to complete is needed to pace the sprint.
  • 24. INVEST in User Stories Independent Negotiable Valuable Estimable Small Quicker to implement, minimize risk, get feedback sooner.
  • 25. INVEST in User Stories Independent Negotiable Valuable Estimable Small Testable A story isn't considered done until its acceptance tests pass.
  • 26. What is an acceptance test? ● Executable version of a refined user story ● Written in domain language ● Scenarios validate story acceptance criteria ● Defines start and finish lines ● Documents value proposition ● Respects "Three Levels of Description"
  • 27. Three Levels of Description Business Rule What is the scenario demonstrating? Scenario: Free delivery is offered to customers who order two or more books
  • 28. Three Levels of Description Business Rule What is the scenario demonstrating? User Workflow How can a user exercise the functionality? Given I put two books in my cart When I checkout Then I should be able to select free delivery
  • 29. Three Levels of Description Business Rule What is the scenario demonstrating? User Workflow How can a user exercise the functionality? Technical Activity What are the technical steps required to exercise each workflow step? step 'I checkout' do click_on 'Checkout' end
  • 31. Disambiguate w/Concrete Examples Scenario Outline: Users cannot sign in after the sixth failed sign in attempt over a one day period Given I have failed to sign in <yesterday> times yesterday And I have failed to sign in <today> times today Then I should be <result> to sign in Examples: | yesterday | today | result | | 0 | 0 | able | | 0 | 5 | able | | 0 | 6 | unable | | 5 | 0 | able | | 5 | 5 | able | | 5 | 6 | unable | | 6 | 0 | able | | 6 | 5 | able | | 6 | 6 | unable |
  • 32. Gherkin Protip: Hide Implementation Scenario: Selected customers are notified of a flash sale Given I am a store manager When I create a flash sale for VIP customers that starts tomorrow And it’s tomorrow And Resque jobs are run Then VIP customers receive a Flashmail
  • 33. Gherkin Protip: Hide Implementation Scenario: Selected customers are notified of a flash sale Given I am a store manager When I create a flash sale for VIP customers Then VIP customers receive a Flashmail the day of the flash
  • 34. Gherkin Protip: Don’t Write Scripts As a party planner with BFFs In order to have the best party ever I want to invite as many BFFs as possible Given there is a user named Alice And there is a user named Bob who is BFFs with Alice And there is a user named Charlie who is BFFs with Bob When Alice invites Bob to a party But Alice does not invite Charlie to the same party Then Alice receives a message "Do you also want to invite Charlie?"
  • 35. Gherkin Protip: Don’t Write Scripts As a party planner with BFFs In order to have the best party ever I want to invite as many BFFs as possible Given I am planning a party When I invite my BFF Bob Then I am asked if I might want to invite his BFF Charlie
  • 36. Gherkin Protip: Be skeptical of "I should see" steps Is the act of seeing the thing valuable to the user or is it an implementation detail? Yes Then I should see that the patron has overdue books No Then I should see the overdue book icon
  • 37. Gherkin Protips: Be skeptical of "And" and “But” keywords Are these steps really one step? Are these steps not focused on the feature? Is this feature really two features? Be skeptical of "and" and "or" in steps Is this step really two steps? Is this scenario really two scenarios?
  • 38. Gherkin Protips: Don't test every case Add examples to disambiguate around edge cases Never use generic steps to DRY tests DRY Ruby code behind the steps Listen when your Gherkin fights you Can you explain the feature in simple terms?
  • 39. Use ctags - Never Grep for Steps ● Open a .feature file ● Move cursor to a scenario step ● Press Ctrl+] to open the step definition ● Press Ctrl+t to go back to the .feature file
  • 40. Step Definitions # Gherkin When I sign up with "email@example.com" and "password" # Cucumber step definition When /^I sign up (?:with|as) "(.*)" and "(.*)"$/ do |email, pw| # More Ruby code here end # Turnip step definition step "I sign up with/as :email and :password" do |email, pw| # More Ruby code here end
  • 41. Use Custom Placeholders step "there are :count monsters" do |count| count.times { Monster.new(name) } end placeholder :count do match /d+/, &:to_i # { |count| count.to_i } match /no/ { 0 } end (or use Step Argument Transforms in Cucumber)
  • 42. Use Helper Methods module MyAccountSteps step 'I am modifying my AwesomeApp account' do sign_in @user = create(:user) select_from_user_drop_down 'My account' end end
  • 43. Organize Your Suite spec |- acceptance |- features |- encouragement.feature |- macros |- session_macros.rb |- steps |- encouragement_steps.rb
  • 44. Every product and team is different, optimize for yours.
  • 46. Learn from smart people http://alindeman.github.io/acceptance_testing http://blog.carbonfive.com/2012/02/14/beginning-outside-in-rails-developmentwith-cucumber-and-rspec/ http://en.wikipedia.org/wiki/INVEST_(mnemonic) http://specificationbyexample.com/ http://janetgregory.blogspot.com/2010/08/atdd-vs-bdd-vs-specification-byexample.html http://www.drdobbs.com/tdd-is-about-design-not-testing/229218691