SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
GHERKIN
ubiquitous language for automated acceptance testing
What’s Gherkin?
• an ubiquitous language for

developers and stakeholders
• aimed for automated 

acceptance tests
• it adheres to BDD
What’s BDD?
Behavior Driven Development
1
2
3
Why Gherkin?
• write executable specifications
• enforce a collaborative approach
• force a specification format
• serve as living documentation
The language
• support for multiple languages
• small set of keywords: 

Feature, Background, Scenario, 

Given, When, Then, And, But, *, 

Scenario Outline, Examples
Feature
• provide summary documentation
• one feature per file
• avoid long descriptions
Feature
Feature: feature title
In order to <meet some goal>
As a <type of stakeholder>
I want <a feature>
Scenario
• describes how system should
behave under a particular
situation
• follows a common pattern: 

context, action, outcome
Scenario
Scenario: Successful withdrawal from an account
Given I have $100 in my account
When I request $20
Then my balance should be $80
context
outcome(s)
action(s)
Scenario
Scenario: Attempt withdrawal using blocked PIN
Given i have $100 in my account
But my PIN is blocked
When i withdraw $50
Then my request should be refuted
And i am forced to reset my PIN
context
outcome(s)
action(s)
Capturing values
• values passed to code as
arguments
• string wrapped by double quotes
• all of the numbers
Scenario: Request a new card
Given I’ve lost my “Visa”
When I request a new card at the “ACME” desk
And I specify a limit of $ 5000 bucks
Then I should be asked for my account details
And I should be provided with a brand new card
Capturing values
Scenario tips
• must make sense to the “others”
• must be executed independently
• must be deterministic
DRY strategies
• share common context
• avoid repeating scenarios
• group similar data
• strength focus on key examples
Scenario: Change PIN successfully
Given I have been issued a new card
And I insert the card, entering the correct PIN
When I choose “Change PIN” from the menu
And I change the PIN to 9876
Then the system should remember my PIN is now 9876
Scenario: Try to change PIN to the same as before
Given I have been issued a new card
And I insert the card, entering the correct PIN
When I choose "Change PIN” from the menu
And I try to change the PIN to the original number
Then I should see a warning message
Background
Background: Insert a newly issued card and sign in
Given I have been issued a new card
And I insert the card, entering the correct PIN
And I choose “Change PIN” from the menu
Scenario: Change PIN successfully
When I change the PIN to 9876
Then the system should remember my PIN is now 9876
Scenario: Try to change PIN to the same as before
When I try to change the PIN to the original number
Then I should see a warning message
Background
Background
• only one per feature file
• short is better
• avoid setting complicated state
• stick with givens
Given a User “Michael Jackson” born on “August 29, 1958”
And a User “Elvis” born on “January 8, 1935”
And a User “John Lennon” born on “October 9, 1940”
Data tables
Given these Users:
| name | date of birth |
| Michael Jackson | August 29, 1958 |
| Elvis | January 8, 1935 |
| John Lennon | October 9, 1940 |
Formatting
spaces are
ignored
Data tables
Scenario: Withdraw fixed amount of $50
Given i have $500 in my account
When i withdraw the fixed amount of $50
Then i should receive $50 cash
And the balance of my account should be $450
Scenario: Withdraw fixed amount of $100
Given i have $500 in my account
When i withdraw the fixed amount of $100
Then i should receive $100 cash
And the balance of my account should be $400
Scenario Outline
Scenario Outline: Withdraw fixed amount
Given i have <balance> in my account
When i withdraw the fixed amount of <withdrawal>
Then i should receive <received> cash
And the balance of my account should be <remaining>
Examples:
| balance | withdrawal | received | remaining |
| $500 | $50 | $50 | $450 |
| $500 | $100 | $100 | $400 |
As many cases
as you need
Scenario Outline
Scenario Outline: Withdraw fixed amount
Given i have <balance> in my account
When i withdraw the fixed amount of <withdrawal>
Then i should <outcome>
And the balance of my account should be <remaining>
Examples: Successful withdrawal
| balance | withdrawal | outcome | remaining |
| $500 | $50 | receive $50 cash | $450 |
Examples: Attempt to withdraw too much
| balance | withdrawal | outcome | remaining |
| $100 | $200 | see an error message | $100 |
Key examples
Best practices
• fix flickering scenarios
• guard from brittle features
• speed up slow features
• avoid bored stakeholders
Incidental details
Scenario: Check inbox
Given a User “Dave” with password “password”
And a User “Sue” with password “secret”
And an email to “Dave” from “Sue”
When i sign in as “Dave” with password “password”
Then i should see 1 email from “Sue” in my inbox
Scenario: Check inbox
Given i have received an email from “Sue”
When i sign in
Then i should see 1 email from “Sue” in my inbox
Incidental details
Imperative VS declarative
Scenario: Redirect user to requested page after logging in
Given a User “dave” exists with password “secret”
And i am not logged in
When i navigate to the home page
Then i am redirected to the login form
When i fill in “Username” with “dave”
And i fill in “Password” with “secret”
And i press “Login”
Then i should be on the home page
Scenario: Redirect user to requested page after logging in
Given i am an unauthenticated User
When i attempt to view some restricted content
Then i am shown a login form
When i authenticate with valid credentials
Then i should be shown the restricted content
Imperative VS declarative
Who’s write Gherkin?
Tester
Developer
Product
Owner
ubiquitous language for automated acceptance testing
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

The tell tale heart sequence of events
The tell tale heart sequence of eventsThe tell tale heart sequence of events
The tell tale heart sequence of events
michael_uprh
 
池澤あやかと学ぼう!: はじめてのOAuthとOpenID Connect - JICS 2014
池澤あやかと学ぼう!: はじめてのOAuthとOpenID Connect - JICS 2014池澤あやかと学ぼう!: はじめてのOAuthとOpenID Connect - JICS 2014
池澤あやかと学ぼう!: はじめてのOAuthとOpenID Connect - JICS 2014
Nov Matake
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
Brandon Keepers
 

Was ist angesagt? (20)

Java vs OOP
Java vs OOPJava vs OOP
Java vs OOP
 
The tell tale heart sequence of events
The tell tale heart sequence of eventsThe tell tale heart sequence of events
The tell tale heart sequence of events
 
Gherkin /BDD intro
Gherkin /BDD introGherkin /BDD intro
Gherkin /BDD intro
 
오래된 프로젝트에 Jenkins 적용해보기
오래된 프로젝트에 Jenkins 적용해보기오래된 프로젝트에 Jenkins 적용해보기
오래된 프로젝트에 Jenkins 적용해보기
 
서비스중인 게임 DB 설계 (쿠키런 편)
서비스중인 게임 DB 설계 (쿠키런 편)서비스중인 게임 DB 설계 (쿠키런 편)
서비스중인 게임 DB 설계 (쿠키런 편)
 
[기본과정] 코드 테스트와 커버리지 기본 교육(개념)
[기본과정] 코드 테스트와 커버리지 기본 교육(개념)[기본과정] 코드 테스트와 커버리지 기본 교육(개념)
[기본과정] 코드 테스트와 커버리지 기본 교육(개념)
 
스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해스프링 시큐리티 구조 이해
스프링 시큐리티 구조 이해
 
(애자일) 테스트 계획서 샘플
(애자일) 테스트 계획서 샘플(애자일) 테스트 계획서 샘플
(애자일) 테스트 계획서 샘플
 
Introduce Katalon tool
Introduce Katalon toolIntroduce Katalon tool
Introduce Katalon tool
 
자주 사용되는 UI 패턴(컴포넌트) 과 UI 레이아웃
자주 사용되는 UI 패턴(컴포넌트) 과 UI 레이아웃자주 사용되는 UI 패턴(컴포넌트) 과 UI 레이아웃
자주 사용되는 UI 패턴(컴포넌트) 과 UI 레이아웃
 
It depends: Loving .NET Core dependency injection or not
It depends: Loving .NET Core dependency injection or notIt depends: Loving .NET Core dependency injection or not
It depends: Loving .NET Core dependency injection or not
 
Rapid prototyping with ScriptableObjects
Rapid prototyping with ScriptableObjectsRapid prototyping with ScriptableObjects
Rapid prototyping with ScriptableObjects
 
池澤あやかと学ぼう!: はじめてのOAuthとOpenID Connect - JICS 2014
池澤あやかと学ぼう!: はじめてのOAuthとOpenID Connect - JICS 2014池澤あやかと学ぼう!: はじめてのOAuthとOpenID Connect - JICS 2014
池澤あやかと学ぼう!: はじめてのOAuthとOpenID Connect - JICS 2014
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
 
장수계보시스템 역기획서
장수계보시스템 역기획서장수계보시스템 역기획서
장수계보시스템 역기획서
 
JQuery UI
JQuery UIJQuery UI
JQuery UI
 
백기선의 스프링 부트
백기선의 스프링 부트백기선의 스프링 부트
백기선의 스프링 부트
 
Hyperledger Aries: Open Source Interoperable Identity Solution – Nathan George
Hyperledger Aries: Open Source Interoperable Identity Solution – Nathan GeorgeHyperledger Aries: Open Source Interoperable Identity Solution – Nathan George
Hyperledger Aries: Open Source Interoperable Identity Solution – Nathan George
 
jQuery
jQueryjQuery
jQuery
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 

Andere mochten auch

Andere mochten auch (10)

A New Dojo: The Art of Story Splitting
A New Dojo: The Art of Story SplittingA New Dojo: The Art of Story Splitting
A New Dojo: The Art of Story Splitting
 
BDD - beyond: Given, When and Then
BDD - beyond: Given, When and ThenBDD - beyond: Given, When and Then
BDD - beyond: Given, When and Then
 
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
Scrum Bangalore 13th meet up 13 june 2015 - behaviour driven development - vi...
 
Specification by example and agile acceptance testing
Specification by example and agile acceptance testingSpecification by example and agile acceptance testing
Specification by example and agile acceptance testing
 
Specification-By-Example with Gherkin
Specification-By-Example with GherkinSpecification-By-Example with Gherkin
Specification-By-Example with Gherkin
 
Behaviour driven development aka bdd
Behaviour driven development aka bddBehaviour driven development aka bdd
Behaviour driven development aka bdd
 
The Art of Gherkin Scripting - Matt Eakin
The Art of Gherkin Scripting - Matt EakinThe Art of Gherkin Scripting - Matt Eakin
The Art of Gherkin Scripting - Matt Eakin
 
Introduction to Bdd and cucumber
Introduction to Bdd and cucumberIntroduction to Bdd and cucumber
Introduction to Bdd and cucumber
 
Specification by Example
Specification by ExampleSpecification by Example
Specification by Example
 
An Overview of User Acceptance Testing (UAT)
An Overview of User Acceptance Testing (UAT)An Overview of User Acceptance Testing (UAT)
An Overview of User Acceptance Testing (UAT)
 

Ähnlich wie Gherkin - crash course

Personal Finance for Engineers
Personal Finance for EngineersPersonal Finance for Engineers
Personal Finance for Engineers
Adam Nash
 
Behavior-Driven Development for UX Teams
Behavior-Driven Development for UX TeamsBehavior-Driven Development for UX Teams
Behavior-Driven Development for UX Teams
Jonathan Abbett
 

Ähnlich wie Gherkin - crash course (12)

Perfecting the pitch with note slides
Perfecting the pitch with note slidesPerfecting the pitch with note slides
Perfecting the pitch with note slides
 
Personal Finance for Engineers (Yelp 2014)
Personal Finance for Engineers (Yelp 2014)Personal Finance for Engineers (Yelp 2014)
Personal Finance for Engineers (Yelp 2014)
 
Armstrong crowdfunding presentation public version
Armstrong crowdfunding presentation   public versionArmstrong crowdfunding presentation   public version
Armstrong crowdfunding presentation public version
 
Personal Finance for Engineers
Personal Finance for EngineersPersonal Finance for Engineers
Personal Finance for Engineers
 
Pete Craig's Presentation
Pete Craig's PresentationPete Craig's Presentation
Pete Craig's Presentation
 
Growing software from examples
Growing software from examplesGrowing software from examples
Growing software from examples
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
 
Message passing
Message passingMessage passing
Message passing
 
Behavior Driven Development [10] - Software Testing Techniques (CIS640)
Behavior Driven Development [10] - Software Testing Techniques (CIS640)Behavior Driven Development [10] - Software Testing Techniques (CIS640)
Behavior Driven Development [10] - Software Testing Techniques (CIS640)
 
Automated UI test on mobile - with Cucumber/Calabash
Automated UI test on mobile - with Cucumber/CalabashAutomated UI test on mobile - with Cucumber/Calabash
Automated UI test on mobile - with Cucumber/Calabash
 
Behavior-Driven Development for UX Teams
Behavior-Driven Development for UX TeamsBehavior-Driven Development for UX Teams
Behavior-Driven Development for UX Teams
 
General Worldcat Ill Revised
General Worldcat Ill RevisedGeneral Worldcat Ill Revised
General Worldcat Ill Revised
 

Mehr von Michele Costa (13)

SIOOT
SIOOTSIOOT
SIOOT
 
SIOOT
SIOOTSIOOT
SIOOT
 
Ozonopatia
OzonopatiaOzonopatia
Ozonopatia
 
SIOOT
SIOOTSIOOT
SIOOT
 
SIOOT
SIOOTSIOOT
SIOOT
 
SIOOT
SIOOTSIOOT
SIOOT
 
SIOOT
SIOOTSIOOT
SIOOT
 
SIOOT
SIOOTSIOOT
SIOOT
 
SIOOT
SIOOTSIOOT
SIOOT
 
SIOOT
SIOOTSIOOT
SIOOT
 
SIOOT
SIOOTSIOOT
SIOOT
 
Il trattamento del Papilloma virus della mucosa Geniena mediante ossigeno-ozo...
Il trattamento del Papilloma virus della mucosa Geniena mediante ossigeno-ozo...Il trattamento del Papilloma virus della mucosa Geniena mediante ossigeno-ozo...
Il trattamento del Papilloma virus della mucosa Geniena mediante ossigeno-ozo...
 
Tariffario ANDI
Tariffario ANDITariffario ANDI
Tariffario ANDI
 

Kürzlich hochgeladen

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Kürzlich hochgeladen (20)

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 

Gherkin - crash course

  • 1. GHERKIN ubiquitous language for automated acceptance testing
  • 2. What’s Gherkin? • an ubiquitous language for
 developers and stakeholders • aimed for automated 
 acceptance tests • it adheres to BDD
  • 3. What’s BDD? Behavior Driven Development 1 2 3
  • 4. Why Gherkin? • write executable specifications • enforce a collaborative approach • force a specification format • serve as living documentation
  • 5. The language • support for multiple languages • small set of keywords: 
 Feature, Background, Scenario, 
 Given, When, Then, And, But, *, 
 Scenario Outline, Examples
  • 6. Feature • provide summary documentation • one feature per file • avoid long descriptions
  • 7. Feature Feature: feature title In order to <meet some goal> As a <type of stakeholder> I want <a feature>
  • 8. Scenario • describes how system should behave under a particular situation • follows a common pattern: 
 context, action, outcome
  • 9. Scenario Scenario: Successful withdrawal from an account Given I have $100 in my account When I request $20 Then my balance should be $80 context outcome(s) action(s)
  • 10. Scenario Scenario: Attempt withdrawal using blocked PIN Given i have $100 in my account But my PIN is blocked When i withdraw $50 Then my request should be refuted And i am forced to reset my PIN context outcome(s) action(s)
  • 11. Capturing values • values passed to code as arguments • string wrapped by double quotes • all of the numbers
  • 12. Scenario: Request a new card Given I’ve lost my “Visa” When I request a new card at the “ACME” desk And I specify a limit of $ 5000 bucks Then I should be asked for my account details And I should be provided with a brand new card Capturing values
  • 13. Scenario tips • must make sense to the “others” • must be executed independently • must be deterministic
  • 14. DRY strategies • share common context • avoid repeating scenarios • group similar data • strength focus on key examples
  • 15. Scenario: Change PIN successfully Given I have been issued a new card And I insert the card, entering the correct PIN When I choose “Change PIN” from the menu And I change the PIN to 9876 Then the system should remember my PIN is now 9876 Scenario: Try to change PIN to the same as before Given I have been issued a new card And I insert the card, entering the correct PIN When I choose "Change PIN” from the menu And I try to change the PIN to the original number Then I should see a warning message Background
  • 16. Background: Insert a newly issued card and sign in Given I have been issued a new card And I insert the card, entering the correct PIN And I choose “Change PIN” from the menu Scenario: Change PIN successfully When I change the PIN to 9876 Then the system should remember my PIN is now 9876 Scenario: Try to change PIN to the same as before When I try to change the PIN to the original number Then I should see a warning message Background
  • 17. Background • only one per feature file • short is better • avoid setting complicated state • stick with givens
  • 18. Given a User “Michael Jackson” born on “August 29, 1958” And a User “Elvis” born on “January 8, 1935” And a User “John Lennon” born on “October 9, 1940” Data tables
  • 19. Given these Users: | name | date of birth | | Michael Jackson | August 29, 1958 | | Elvis | January 8, 1935 | | John Lennon | October 9, 1940 | Formatting spaces are ignored Data tables
  • 20. Scenario: Withdraw fixed amount of $50 Given i have $500 in my account When i withdraw the fixed amount of $50 Then i should receive $50 cash And the balance of my account should be $450 Scenario: Withdraw fixed amount of $100 Given i have $500 in my account When i withdraw the fixed amount of $100 Then i should receive $100 cash And the balance of my account should be $400 Scenario Outline
  • 21. Scenario Outline: Withdraw fixed amount Given i have <balance> in my account When i withdraw the fixed amount of <withdrawal> Then i should receive <received> cash And the balance of my account should be <remaining> Examples: | balance | withdrawal | received | remaining | | $500 | $50 | $50 | $450 | | $500 | $100 | $100 | $400 | As many cases as you need Scenario Outline
  • 22. Scenario Outline: Withdraw fixed amount Given i have <balance> in my account When i withdraw the fixed amount of <withdrawal> Then i should <outcome> And the balance of my account should be <remaining> Examples: Successful withdrawal | balance | withdrawal | outcome | remaining | | $500 | $50 | receive $50 cash | $450 | Examples: Attempt to withdraw too much | balance | withdrawal | outcome | remaining | | $100 | $200 | see an error message | $100 | Key examples
  • 23. Best practices • fix flickering scenarios • guard from brittle features • speed up slow features • avoid bored stakeholders
  • 24. Incidental details Scenario: Check inbox Given a User “Dave” with password “password” And a User “Sue” with password “secret” And an email to “Dave” from “Sue” When i sign in as “Dave” with password “password” Then i should see 1 email from “Sue” in my inbox
  • 25. Scenario: Check inbox Given i have received an email from “Sue” When i sign in Then i should see 1 email from “Sue” in my inbox Incidental details
  • 26. Imperative VS declarative Scenario: Redirect user to requested page after logging in Given a User “dave” exists with password “secret” And i am not logged in When i navigate to the home page Then i am redirected to the login form When i fill in “Username” with “dave” And i fill in “Password” with “secret” And i press “Login” Then i should be on the home page
  • 27. Scenario: Redirect user to requested page after logging in Given i am an unauthenticated User When i attempt to view some restricted content Then i am shown a login form When i authenticate with valid credentials Then i should be shown the restricted content Imperative VS declarative
  • 29. ubiquitous language for automated acceptance testing Questions?