SlideShare une entreprise Scribd logo
1  sur  68
Télécharger pour lire hors ligne
A C C E P TA N C E T E S T D R I V E N D E V E L O P M E N T
B Y E X A M P L E W I T H C U C U M B E R
W H O W E A R E .
@ D O U G M O R G A N _
G I T H U B . C O M / D M O R G A N 3 4 0 5
D O U G M O R G A N
@ C H Z Ygithub.com/chzy
J E F F M O R G A N
W O R K I N G A G R E E M E N T S
• Help each other out.
• You aren't done until the person next to you is done.
• Time boxed breaks.
• Respect your peers; please don't be late.
• Ask questions.
• Speak up if you don't understand something.
M O R N I N G A G E N D A
• Acceptance Test Driven Development
• Why?
• What?
• Shared Understanding/ Collaboration
• Three Amigos
• Acceptance Criteria
• Gherkin
• Cucumber
A F T E R N O O N A G E N D A
• PageObject
• Interacting with a web browser
• Cleaner scenarios
• Asserting requirements
• Q & A
W H Y AT D D ?
F I R S T O F F.
W H Y AT D D ?
T >
^
F
X
W H Y AT D D ?
• Clear definition of done
• Over building.
• Under building.
• Avoiding Rework
• Due to not understanding requirements.
• Avoid Context Switching
R E D U C E WA S T E .
B A S I C A L LY.
W H AT I S AT D D ?
Acceptance Test Driven Development
– M E R R I A M - W E B S T E R D I C T I O N A RY
“The quality or state of being
accepted or acceptable”
Copyright LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.
Ready Development Test Review Done
Product
Owner
Developer Tester
Copyright LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission.
Ready Development Test Review Done
Product
Owner
Developer Tester
Meeting
?
Done
TrackingPriority
Not
Done
Done
UX
Done
Not
Done
Not
Done
WA S T E .
R E W O R K R E S U LT S I N
S H A R E D U N D E R S TA N D I N G
DeveloperProduct
Owner
Tester
M U LT I P L E
P E R S P E C T I V E S
S H A R E D U N D E R S TA N D I N G
Written words are the
second worst form of
communication
S H A R E D U N D E R S TA N D I N G
1. 2.
3. 4.
"I'm glad we all agree"
"Ah!" "I'm glad we're all agreed then"
"Ah!"
Clear Communication
*The Agile Samurai - Jonathan Rasmusson
S H A R E D U N D E R S TA N D I N G
DeveloperProduct
Owner
Tester
¡Arriba!
T H E “ T H R E E A M I G O S ”
G H E R K I N S Y N TA X
Feature: …
Scenario: …
Given …
When …
And …
Then …
S H A R E D U N D E R S TA N D I N G
S H A R E D U N D E R S TA N D I N G
S H A R E D U N D E R S TA N D I N G
As a credit card paying customer,
I want to be informed when the credit card
information I have entered is in an invalid format.
So that I can correct my information and successfully complete
my transaction.
S H A R E D U N D E R S TA N D I N G
Feature: Entering credit card information
Scenario: Credit card number too short
Scenario: Expiration date invalid
S H A R E D U N D E R S TA N D I N G
Scenario: Credit card number too short
Given I have chosen some items to buy
And I am about to enter my credit card details
When I enter a card number that's only 15 digits long
Then I expect the page to be redisplayed
And I expect to see “Credit card must be at least 16 digits”
S H A R E D U N D E R S TA N D I N G
Scenario: Expiration date invalid
Given I have chosen some items to buy
And I am about to enter my credit card details
When I enter a card expiration date that's in the past
Then I expect the page to be redisplayed
And I expect to see “Incorrect expiration date”
brush
tooth
paste
bristles
water
Varieties of Language in Cucumber Scenarios
TA U T O L O G I C A L
Scenario: Search for a Book
When I search for a book
Then I should see the correct results
S U P E R T E C H N I C A L
Scenario: Search for a book
Given the following Authors:
| id | name |
| 1 | Charles Dickens |
| 2 | John Steinbeck |
| 3 | Fyodor Dostoyevsky |
And the following Titles:
| id | title | author_id |
| 1 | A Tale of Two Cities | 1 |
| 2 | Crime and Punishment | 3 |
| 3 | East of Eden | 2 |
And I'm on "http://www.bookstore.biz/"
When I fill in "Dickens" in "//input[name()='q']"
And I click "#searchButton"
Then there should be 1 "div.book div.title" element
And the page should contain "A Tale of Two Cities"
S C R I P T Y, W I T H I M P L E M E N TAT I O N D E TA I L S
Scenario: Search for a book
Given the following catalog:
| Title | Author |
| A Tale of Two Cities | Charles Dickens |
| Crime and Punishment | Fyodor Dostoyevsky |
| East of Eden | John Steinbeck |
And I'm on the bookstore home page
When I fill in "Dickens" in the search field
And I click "Search"
Then I should see only "A Tale of Two Cities" in the results
E X A M P L E I N D O M A I N L A N G U A G E
Scenario: Search for a book
Given the following catalog:
| Title | Author |
| A Tale of Two Cities | Charles Dickens |
| Crime and Punishment | Fyodor Dostoyevsky |
| East of Eden | John Steinbeck |
When I search for "Dickens"
Then I should see only "A Tale of Two Cities" in the results
E X A M P L E I N D O M A I N L A N G U A G E 

W I T H E X C E S S D E TA I L
Scenario: Search for a book
Given the following catalog:
| Title | Author | Publisher | ISBN |
| A Tale of Two Cities | Charles Dickens | Qualitas Classics| 1897093594 |
| Crime and Punishment | Fyodor Dostoyevsky| Simon & Brown | 1936041030 |
| East of Eden | John Steinbeck | Penguin | 0142000655 |
When I search for "Dickens"
Then I should see only the following in the results:
| Title | Author | Format | Price |
| A Tale of Two Cities | Charles Dickens | Paperback | $14.90 |
D I F F E R E N T K I N D S O F S C E N A R I O S
Tautologi
Dom
ain
Language
Dom
ain
LanguageIm
plem
entationSuper

Sweet
E X E R C I S E
Identify different kinds of scenarios
Acceptance Test Driven Development
W H E N S H O U L D W E T E S T O U R C O D E ?
TestCode
Code TestMonths
Code TestWeeks
Code TestDays
W H E N S H O U L D W E T E S T O U R C O D E ?
S T O RY T W O
Code TestS T O RY O N E
S T O RY T W O
S T O RY T W O
Context
Switching
S T O RY O N E
R E W O R K
S T O RY O N E
R E W O R K
C O N T E X T - S W I T C H I N G
= WA S T E .
W H E N S H O U L D W E T E S T O U R C O D E ?
Write
Test
Run
Test
Code Run
Test
Run
Test
Run
Test
T E S T D R I V E N
1. Red
- Write a failing test.
2. Green
- Write code to make the test pass.
3. Refactor
- Preserve the behavior.
- Clean up the code.
http://stackoverflow.com/questions/28372861/cucumber-js-for-bdd-unit-testing
L E T S G E T T O W O R K !
https://github.com/dmorgan3405/ATDD-By-Example.git
git clone
D E M O
• Open the browser
• Navigate to
puppies.herokuapp.com
• Close the browser
Checkpoint: example_of_driving_a_browser
PA R T D E U X
A C C E P TA N C E T E S T D R I V E N D E V E L O P M E N T
W O R K I N G A G R E E M E N T S ( R E M I N D E R )
• Help each other out.
• You aren't done until the person next to you is done.
• Time boxed breaks.
• Respect your peers; please don't be late.
• Ask questions.
• Speak up if you don't understand something.
T O O L B E LT
C O M M O N LY U S E D R U B Y G E M S
• cucumber
• watir-webdriver
• page-object
• rspec
• nokogiri
• active-record
• factory_girl
• savon
• data_magic
PA G E O B J E C T
“A simple gem that assists in creating flexible
page objects for testing browser based
applications. The goal is to facilitate creating
abstraction layers in your tests to decouple the
tests from the item they are testing and to
provide a simple interface to the elements on
a page. It works with both watir-webdriver and
selenium-webdriver.”
* W W W. G I T H U B . C O M / C H E E Z Y / PA G E - O B J E C T / B L O B / M A S T E R / R E A D M E . M D
P I C K A B R O W S E R
• Firefox
• Nothing extra is needed.
• Chrome
• Driver needed. (https://sites.google.com/a/chromium.org/chromedriver/downloads)
• Put in path.
• Internet Explorer
• Driver needed.
• Security Zones protection setting need to be the same.
• Zoom set to 100%.
PA G E O B J E C T A P I
Use the Quick reference guide inside of the repository!
PA G E FA C T O RY
To visit a page, then preform the action use
visit_page(HomePage).action_to_do
or
visit_page(HomePage) do |page|
page.action_to_do
end
PA G E FA C T O RY
To preform the action on the current page
on_page(HomePage).action_to_do
or
on_page(HomePage) do |page|
page.action_to_do
end
L E T S A D O P T A P U P P Y !
L E T S A D O P T A P U P P Y !
Feature: Adopting a puppy
As a puppy lover
I want to adopt puppies
So that ...
Background:
Given I am on the puppy adoption site
Scenario: Adopting a puppy
When I view the details of the first puppy
And I choose to adopt the puppy
And I enter my name "Your Name Here"
And I enter my address "1151 N Marginal Rd"
And I enter my email "you@example.com"
And I choose to pay by "Credit card"
And I choose to place my order
Then I should see "Thank you for adopting a puppy!"
Checkpoint: start_adopting_a_puppy
A D D I N G V E R I F I C AT I O N
How would you verify
the thank you
message is displayed?
Checkpoint: example_of_adding_verification
W I T H C U C U M B E R TA B L E S
H I G H E R L E V E L T E S T S
Cucumber::MultilineArgument::DataTable
#hashes
Returns Array of Hashes
Checkpoint: start_using_cucumber_tables
P O P U L AT E PA G E W I T H
This method will populate all matched page elements from the
Hash passed as an argument.
• TextFields
• TextAreas
• SelectLists
• FileFields
• Checkboxes
• Radio Buttons
The way it find an element is by matching the Hash key to the
name you provided when declaring the element on your page.
P O P U L AT E PA G E W I T H
class ExamplePage
include PageObject
text_field(: name, :index => 0)
FORM_DATA = {:name => ‘Test User’}
def fill_form
populate_page_with(FORM_DATA)
end
end
Checkpoint: example_of_using_populate_page_with
D ATA M A G I C
An easy to use gem that provides datasets
that can be used by your application and
tests. The data is stored in yaml files.
Checkpoint: example_of_data_magic
N O W L E T S A D O P T T W O
P U P P I E S !
Feature: Adopting multiple puppies
As a puppy lover
I want to adopt multiple puppies
So that ...
Background:
Given I am on the puppy adoption site
Scenario: Adopting multiple puppies
When I adopt puppy 1
And I choose to adopt another puppy
And I adopt puppy 2
And I choose to complete the adoption
And I checkout
Then I should see "Thank you for adopting a puppy!"
Checkpoint: start_adopting_two_puppies
S C E N A R I O O U T L I N E S
Checkpoint: start_using_scenario_outlines
Scenario Outline: Shopping cart offers common accessories
When I adopt puppy 1
Then I should see "<accessory>" as an optional accessory
Examples:
| accessory |
| Collar & Leash |
| Chew Toy |
| Travel Carrier |
| First Vet Visit |
TA B L E VA L I D AT I O N S
What should we tests?
TA B L E VA L I D AT I O N S
• Verify one name, puppy price and cart total.
***Bonus***
• Verify two names, puppy prices, and cart total.
Checkpoint: start_validating_shopping_cart
Q U E S T I O N S ?
Q & A
T H A N K Y O U !
Jeff Morgan
@chzy
github.com/cheezy
Doug Morgan
@dougmorgan_
github.com/dmorgan3405

Contenu connexe

Similaire à ATDD BY Example With Cucumber

Reduce, Reuse, Refactor
Reduce, Reuse, RefactorReduce, Reuse, Refactor
Reduce, Reuse, Refactorcklosowski
 
Reduce, Reuse, Refactor
Reduce, Reuse, RefactorReduce, Reuse, Refactor
Reduce, Reuse, Refactorcklosowski
 
From Content Strategy to Drupal Site Building - Connecting the dots
From Content Strategy to Drupal Site Building - Connecting the dotsFrom Content Strategy to Drupal Site Building - Connecting the dots
From Content Strategy to Drupal Site Building - Connecting the dotsRonald Ashri
 
From Content Strategy to Drupal Site Building - Connecting the Dots
From Content Strategy to Drupal Site Building - Connecting the DotsFrom Content Strategy to Drupal Site Building - Connecting the Dots
From Content Strategy to Drupal Site Building - Connecting the DotsRonald Ashri
 
Choosing the right database
Choosing the right databaseChoosing the right database
Choosing the right databaseDavid Simons
 
Choosing the Right Database
Choosing the Right DatabaseChoosing the Right Database
Choosing the Right DatabaseDavid Simons
 
Data Modelling at Scale
Data Modelling at ScaleData Modelling at Scale
Data Modelling at ScaleDavid Simons
 
Backpack Reporting (Updated)
Backpack Reporting (Updated)Backpack Reporting (Updated)
Backpack Reporting (Updated)Steve Johnson
 
Canary Deployments on Amazon EKS with Istio - SRV305 - Chicago AWS Summit
Canary Deployments on Amazon EKS with Istio - SRV305 - Chicago AWS SummitCanary Deployments on Amazon EKS with Istio - SRV305 - Chicago AWS Summit
Canary Deployments on Amazon EKS with Istio - SRV305 - Chicago AWS SummitAmazon Web Services
 
Why Customer Experience is Actually SEO
Why Customer Experience is Actually SEOWhy Customer Experience is Actually SEO
Why Customer Experience is Actually SEOGareth Cartman
 
Design for your audience
Design for your audienceDesign for your audience
Design for your audienceWalter Breakell
 
iOS quick grab on XCTest XCUITest
iOS quick grab on XCTest XCUITestiOS quick grab on XCTest XCUITest
iOS quick grab on XCTest XCUITestDucCongNguyen1
 
Four Architectural Patterns
Four Architectural Patterns Four Architectural Patterns
Four Architectural Patterns David Simons
 
Switching horses midstream - From Waterfall to Agile
Switching horses midstream - From Waterfall to AgileSwitching horses midstream - From Waterfall to Agile
Switching horses midstream - From Waterfall to AgileDoc Norton
 
Walk of Claim - A Meteor Meetup presentation
Walk of Claim - A Meteor Meetup presentationWalk of Claim - A Meteor Meetup presentation
Walk of Claim - A Meteor Meetup presentationStephan Hochhaus
 

Similaire à ATDD BY Example With Cucumber (20)

Reduce, Reuse, Refactor
Reduce, Reuse, RefactorReduce, Reuse, Refactor
Reduce, Reuse, Refactor
 
Reduce, Reuse, Refactor
Reduce, Reuse, RefactorReduce, Reuse, Refactor
Reduce, Reuse, Refactor
 
From Content Strategy to Drupal Site Building - Connecting the dots
From Content Strategy to Drupal Site Building - Connecting the dotsFrom Content Strategy to Drupal Site Building - Connecting the dots
From Content Strategy to Drupal Site Building - Connecting the dots
 
From Content Strategy to Drupal Site Building - Connecting the Dots
From Content Strategy to Drupal Site Building - Connecting the DotsFrom Content Strategy to Drupal Site Building - Connecting the Dots
From Content Strategy to Drupal Site Building - Connecting the Dots
 
Choosing the right database
Choosing the right databaseChoosing the right database
Choosing the right database
 
Choosing the Right Database
Choosing the Right DatabaseChoosing the Right Database
Choosing the Right Database
 
Smoke tests and mirrors
Smoke tests and mirrorsSmoke tests and mirrors
Smoke tests and mirrors
 
Data Modelling at Scale
Data Modelling at ScaleData Modelling at Scale
Data Modelling at Scale
 
Take the red pill
Take the red pillTake the red pill
Take the red pill
 
Backpack Reporting (Updated)
Backpack Reporting (Updated)Backpack Reporting (Updated)
Backpack Reporting (Updated)
 
WordCamp Clients
WordCamp ClientsWordCamp Clients
WordCamp Clients
 
Canary Deployments on Amazon EKS with Istio - SRV305 - Chicago AWS Summit
Canary Deployments on Amazon EKS with Istio - SRV305 - Chicago AWS SummitCanary Deployments on Amazon EKS with Istio - SRV305 - Chicago AWS Summit
Canary Deployments on Amazon EKS with Istio - SRV305 - Chicago AWS Summit
 
Why Customer Experience is Actually SEO
Why Customer Experience is Actually SEOWhy Customer Experience is Actually SEO
Why Customer Experience is Actually SEO
 
Design for your audience
Design for your audienceDesign for your audience
Design for your audience
 
iOS quick grab on XCTest XCUITest
iOS quick grab on XCTest XCUITestiOS quick grab on XCTest XCUITest
iOS quick grab on XCTest XCUITest
 
Four Architectural Patterns
Four Architectural Patterns Four Architectural Patterns
Four Architectural Patterns
 
Switching horses midstream - From Waterfall to Agile
Switching horses midstream - From Waterfall to AgileSwitching horses midstream - From Waterfall to Agile
Switching horses midstream - From Waterfall to Agile
 
Walk of Claim - A Meteor Meetup presentation
Walk of Claim - A Meteor Meetup presentationWalk of Claim - A Meteor Meetup presentation
Walk of Claim - A Meteor Meetup presentation
 
El marketing ha muerto
El marketing ha muertoEl marketing ha muerto
El marketing ha muerto
 
Yes, you can git!
Yes, you can git!Yes, you can git!
Yes, you can git!
 

Dernier

WomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneWomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneUiPathCommunity
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfROWELL MARQUINA
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Français Patch Tuesday - Avril
Français Patch Tuesday - AvrilFrançais Patch Tuesday - Avril
Français Patch Tuesday - AvrilIvanti
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 

Dernier (20)

WomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyoneWomenInAutomation2024: AI and Automation for eveyone
WomenInAutomation2024: AI and Automation for eveyone
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdf
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Français Patch Tuesday - Avril
Français Patch Tuesday - AvrilFrançais Patch Tuesday - Avril
Français Patch Tuesday - Avril
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
How Tech Giants Cut Corners to Harvest Data for A.I.
How Tech Giants Cut Corners to Harvest Data for A.I.How Tech Giants Cut Corners to Harvest Data for A.I.
How Tech Giants Cut Corners to Harvest Data for A.I.
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 

ATDD BY Example With Cucumber

  • 1. A C C E P TA N C E T E S T D R I V E N D E V E L O P M E N T B Y E X A M P L E W I T H C U C U M B E R
  • 2. W H O W E A R E .
  • 3. @ D O U G M O R G A N _ G I T H U B . C O M / D M O R G A N 3 4 0 5 D O U G M O R G A N
  • 4. @ C H Z Ygithub.com/chzy J E F F M O R G A N
  • 5. W O R K I N G A G R E E M E N T S • Help each other out. • You aren't done until the person next to you is done. • Time boxed breaks. • Respect your peers; please don't be late. • Ask questions. • Speak up if you don't understand something.
  • 6. M O R N I N G A G E N D A • Acceptance Test Driven Development • Why? • What? • Shared Understanding/ Collaboration • Three Amigos • Acceptance Criteria • Gherkin • Cucumber
  • 7. A F T E R N O O N A G E N D A • PageObject • Interacting with a web browser • Cleaner scenarios • Asserting requirements • Q & A
  • 8. W H Y AT D D ? F I R S T O F F.
  • 9. W H Y AT D D ? T > ^ F X
  • 10. W H Y AT D D ? • Clear definition of done • Over building. • Under building. • Avoiding Rework • Due to not understanding requirements. • Avoid Context Switching
  • 11. R E D U C E WA S T E . B A S I C A L LY.
  • 12. W H AT I S AT D D ?
  • 13. Acceptance Test Driven Development
  • 14. – M E R R I A M - W E B S T E R D I C T I O N A RY “The quality or state of being accepted or acceptable”
  • 15. Copyright LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Test Review Done Product Owner Developer Tester
  • 16. Copyright LeanDog, Inc. All Rights Reserved. Do not copy or distribute without permission. Ready Development Test Review Done Product Owner Developer Tester Meeting ? Done TrackingPriority Not Done Done UX Done Not Done Not Done
  • 17. WA S T E . R E W O R K R E S U LT S I N
  • 18. S H A R E D U N D E R S TA N D I N G DeveloperProduct Owner Tester M U LT I P L E P E R S P E C T I V E S
  • 19. S H A R E D U N D E R S TA N D I N G Written words are the second worst form of communication
  • 20. S H A R E D U N D E R S TA N D I N G 1. 2. 3. 4. "I'm glad we all agree" "Ah!" "I'm glad we're all agreed then" "Ah!" Clear Communication *The Agile Samurai - Jonathan Rasmusson
  • 21. S H A R E D U N D E R S TA N D I N G DeveloperProduct Owner Tester ¡Arriba! T H E “ T H R E E A M I G O S ”
  • 22. G H E R K I N S Y N TA X Feature: … Scenario: … Given … When … And … Then … S H A R E D U N D E R S TA N D I N G
  • 23. S H A R E D U N D E R S TA N D I N G
  • 24. S H A R E D U N D E R S TA N D I N G As a credit card paying customer, I want to be informed when the credit card information I have entered is in an invalid format. So that I can correct my information and successfully complete my transaction.
  • 25. S H A R E D U N D E R S TA N D I N G Feature: Entering credit card information Scenario: Credit card number too short Scenario: Expiration date invalid
  • 26. S H A R E D U N D E R S TA N D I N G Scenario: Credit card number too short Given I have chosen some items to buy And I am about to enter my credit card details When I enter a card number that's only 15 digits long Then I expect the page to be redisplayed And I expect to see “Credit card must be at least 16 digits”
  • 27. S H A R E D U N D E R S TA N D I N G Scenario: Expiration date invalid Given I have chosen some items to buy And I am about to enter my credit card details When I enter a card expiration date that's in the past Then I expect the page to be redisplayed And I expect to see “Incorrect expiration date”
  • 29.
  • 30. Varieties of Language in Cucumber Scenarios
  • 31. TA U T O L O G I C A L Scenario: Search for a Book When I search for a book Then I should see the correct results
  • 32. S U P E R T E C H N I C A L Scenario: Search for a book Given the following Authors: | id | name | | 1 | Charles Dickens | | 2 | John Steinbeck | | 3 | Fyodor Dostoyevsky | And the following Titles: | id | title | author_id | | 1 | A Tale of Two Cities | 1 | | 2 | Crime and Punishment | 3 | | 3 | East of Eden | 2 | And I'm on "http://www.bookstore.biz/" When I fill in "Dickens" in "//input[name()='q']" And I click "#searchButton" Then there should be 1 "div.book div.title" element And the page should contain "A Tale of Two Cities"
  • 33. S C R I P T Y, W I T H I M P L E M E N TAT I O N D E TA I L S Scenario: Search for a book Given the following catalog: | Title | Author | | A Tale of Two Cities | Charles Dickens | | Crime and Punishment | Fyodor Dostoyevsky | | East of Eden | John Steinbeck | And I'm on the bookstore home page When I fill in "Dickens" in the search field And I click "Search" Then I should see only "A Tale of Two Cities" in the results
  • 34. E X A M P L E I N D O M A I N L A N G U A G E Scenario: Search for a book Given the following catalog: | Title | Author | | A Tale of Two Cities | Charles Dickens | | Crime and Punishment | Fyodor Dostoyevsky | | East of Eden | John Steinbeck | When I search for "Dickens" Then I should see only "A Tale of Two Cities" in the results
  • 35. E X A M P L E I N D O M A I N L A N G U A G E 
 W I T H E X C E S S D E TA I L Scenario: Search for a book Given the following catalog: | Title | Author | Publisher | ISBN | | A Tale of Two Cities | Charles Dickens | Qualitas Classics| 1897093594 | | Crime and Punishment | Fyodor Dostoyevsky| Simon & Brown | 1936041030 | | East of Eden | John Steinbeck | Penguin | 0142000655 | When I search for "Dickens" Then I should see only the following in the results: | Title | Author | Format | Price | | A Tale of Two Cities | Charles Dickens | Paperback | $14.90 |
  • 36. D I F F E R E N T K I N D S O F S C E N A R I O S Tautologi Dom ain Language Dom ain LanguageIm plem entationSuper
 Sweet
  • 37. E X E R C I S E Identify different kinds of scenarios
  • 38. Acceptance Test Driven Development
  • 39. W H E N S H O U L D W E T E S T O U R C O D E ? TestCode Code TestMonths Code TestWeeks Code TestDays
  • 40. W H E N S H O U L D W E T E S T O U R C O D E ? S T O RY T W O Code TestS T O RY O N E S T O RY T W O S T O RY T W O Context Switching S T O RY O N E R E W O R K S T O RY O N E R E W O R K C O N T E X T - S W I T C H I N G = WA S T E .
  • 41. W H E N S H O U L D W E T E S T O U R C O D E ? Write Test Run Test Code Run Test Run Test Run Test
  • 42. T E S T D R I V E N 1. Red - Write a failing test. 2. Green - Write code to make the test pass. 3. Refactor - Preserve the behavior. - Clean up the code.
  • 44. L E T S G E T T O W O R K ! https://github.com/dmorgan3405/ATDD-By-Example.git git clone
  • 45. D E M O • Open the browser • Navigate to puppies.herokuapp.com • Close the browser Checkpoint: example_of_driving_a_browser
  • 46. PA R T D E U X A C C E P TA N C E T E S T D R I V E N D E V E L O P M E N T
  • 47. W O R K I N G A G R E E M E N T S ( R E M I N D E R ) • Help each other out. • You aren't done until the person next to you is done. • Time boxed breaks. • Respect your peers; please don't be late. • Ask questions. • Speak up if you don't understand something.
  • 48. T O O L B E LT
  • 49. C O M M O N LY U S E D R U B Y G E M S • cucumber • watir-webdriver • page-object • rspec • nokogiri • active-record • factory_girl • savon • data_magic
  • 50. PA G E O B J E C T “A simple gem that assists in creating flexible page objects for testing browser based applications. The goal is to facilitate creating abstraction layers in your tests to decouple the tests from the item they are testing and to provide a simple interface to the elements on a page. It works with both watir-webdriver and selenium-webdriver.” * W W W. G I T H U B . C O M / C H E E Z Y / PA G E - O B J E C T / B L O B / M A S T E R / R E A D M E . M D
  • 51. P I C K A B R O W S E R • Firefox • Nothing extra is needed. • Chrome • Driver needed. (https://sites.google.com/a/chromium.org/chromedriver/downloads) • Put in path. • Internet Explorer • Driver needed. • Security Zones protection setting need to be the same. • Zoom set to 100%.
  • 52. PA G E O B J E C T A P I Use the Quick reference guide inside of the repository!
  • 53. PA G E FA C T O RY To visit a page, then preform the action use visit_page(HomePage).action_to_do or visit_page(HomePage) do |page| page.action_to_do end
  • 54. PA G E FA C T O RY To preform the action on the current page on_page(HomePage).action_to_do or on_page(HomePage) do |page| page.action_to_do end
  • 55. L E T S A D O P T A P U P P Y !
  • 56. L E T S A D O P T A P U P P Y ! Feature: Adopting a puppy As a puppy lover I want to adopt puppies So that ... Background: Given I am on the puppy adoption site Scenario: Adopting a puppy When I view the details of the first puppy And I choose to adopt the puppy And I enter my name "Your Name Here" And I enter my address "1151 N Marginal Rd" And I enter my email "you@example.com" And I choose to pay by "Credit card" And I choose to place my order Then I should see "Thank you for adopting a puppy!" Checkpoint: start_adopting_a_puppy
  • 57. A D D I N G V E R I F I C AT I O N How would you verify the thank you message is displayed? Checkpoint: example_of_adding_verification
  • 58. W I T H C U C U M B E R TA B L E S H I G H E R L E V E L T E S T S
  • 59. Cucumber::MultilineArgument::DataTable #hashes Returns Array of Hashes Checkpoint: start_using_cucumber_tables
  • 60. P O P U L AT E PA G E W I T H This method will populate all matched page elements from the Hash passed as an argument. • TextFields • TextAreas • SelectLists • FileFields • Checkboxes • Radio Buttons The way it find an element is by matching the Hash key to the name you provided when declaring the element on your page.
  • 61. P O P U L AT E PA G E W I T H class ExamplePage include PageObject text_field(: name, :index => 0) FORM_DATA = {:name => ‘Test User’} def fill_form populate_page_with(FORM_DATA) end end Checkpoint: example_of_using_populate_page_with
  • 62. D ATA M A G I C An easy to use gem that provides datasets that can be used by your application and tests. The data is stored in yaml files. Checkpoint: example_of_data_magic
  • 63. N O W L E T S A D O P T T W O P U P P I E S ! Feature: Adopting multiple puppies As a puppy lover I want to adopt multiple puppies So that ... Background: Given I am on the puppy adoption site Scenario: Adopting multiple puppies When I adopt puppy 1 And I choose to adopt another puppy And I adopt puppy 2 And I choose to complete the adoption And I checkout Then I should see "Thank you for adopting a puppy!" Checkpoint: start_adopting_two_puppies
  • 64. S C E N A R I O O U T L I N E S Checkpoint: start_using_scenario_outlines Scenario Outline: Shopping cart offers common accessories When I adopt puppy 1 Then I should see "<accessory>" as an optional accessory Examples: | accessory | | Collar & Leash | | Chew Toy | | Travel Carrier | | First Vet Visit |
  • 65. TA B L E VA L I D AT I O N S What should we tests?
  • 66. TA B L E VA L I D AT I O N S • Verify one name, puppy price and cart total. ***Bonus*** • Verify two names, puppy prices, and cart total. Checkpoint: start_validating_shopping_cart
  • 67. Q U E S T I O N S ? Q & A
  • 68. T H A N K Y O U ! Jeff Morgan @chzy github.com/cheezy Doug Morgan @dougmorgan_ github.com/dmorgan3405