SlideShare a Scribd company logo
1 of 19
Download to read offline
The complete
guide to BDD +
Cucumber
Best Practices
and Anti-Patterns
with Test
Automation
BDD and tools like Cucumber, when used correctly,
should add significant value to your organisation’s
project delivery, product quality and customer
satisfaction.
…when used correctly…
And herein lies the problem. They are highly prone to
unintentional misuse that quickly diminishes their
value-add.
More often than not, the process and the tools are used
poorly and in a manner far from the intention of the
teams that built them.
In this webinar, we’ll take you through the complete
guide of firmly accepted best practices to embrace
and anti-patterns to avoid when starting to use these
tools and processes in your organisation.
Chair a collaborative
3-amigos
requirements forum
with your Product
Owners, Developers
and Testers.
Collaborate and communicate.
Discuss and Question the requirements.
Explore the What ifs and the Edge Cases.
Capture the agreed outcomes and desired
behaviours in a BDD Scenario.
Product Owners can outline a basic intent,
Developers can lead the technical discussion and
Testers can lead an exploration of the boundaries
and the unexpected.
Do not have Team Members write Features and
Scenarios in isolation.
Do not write BDD scenarios after you have already
implemented a feature.
BDD is first and foremost about a conversation. If
you’re not conversing you are not ‘doing’ BDD.
Focus on describing
the end-to-end
journey the customer
is undertaking, not
how they are
executing it.
Avoid combining
multiple requirements.
Bad
Given an unregistered user is on the Amazon UK website
When they click in the Search field
And enter ‘Headphones’
And click search
Then they see a Search Results page
When they select a product
Then they see a Product Details Page
When they add quantity ‘2’
And click on ‘Add to cart’
Then they are able to complete a successful checkout
● Choose declarative over imperative
● Embrace singularity
● Anyone should be able to immediately understand the flow
● The steps in Ex1 should be contained in the Step Defs only
● Changes in UI flow will break scenarios
Good
Given an unregistered user is on the Amazon UK website
When they search for a product
And add it to cart
Then they are able to complete a successful checkout
Bad
Given an unregistered user is on the Amazon UK website
When they search for a product
And add it to cart
Then they are able to complete a successful checkout
And they can then register as a new user
Use your Given as a
starting journey state,
your When as a series
of user actions and
your Then as a
verification point.
● Past, present and Future tense
● Background Steps
● Feature Narratives
● And + But in moderation
● 1st vs 3rd person
Better - ‘Past, Present and Future’ OR ‘Present’ all the way
and introducing Narratives and Background steps.
Feature: UK Checkouts
As a user I wish to checkout with a product I’ve chosen
Background:
Given an unregistered user went to the Amazon UK website
Scenario: Successful Amazon UK Checkout
When they search for a product
And add it to cart
Then they will be able to complete a successful checkout
OK - Bad Tense usage
Given I will go to the Amazon UK website
When I searched for a product
And added it to cart
Then I can complete a successful checkout
Use grammatically
correct, concise,
natural language
with basic business
process terminology
as required.
Positive and Negative
behaviours.
● Capture what should
happen as well as what
shouldn’t
● How should the
application fail gracefully
in the event of an
unexpected user
behaviour?
● Which error messages
should the customer see
in which circumstances?
If your working with a
Spanish customer, use
Spanish. Given a user is on the Amazon website
When they search for a product
And add it to their cart
Then they can checkout successfully
Dado que un usuario está en el sitio web de
Amazon
Cuando buscan un producto
Y añádelo a su carrito.
Entonces pueden pagar con éxito
● Watch the buy-in of your
customer and the shared
collaboration with them
skyrocket if you can
embrace a local language
● In your requirements
management tool, for
example JIRA, why not
capture both versions? 1
for the customer and 1 for
the delivery team.
Don’t force the re-use
of scenario steps for
automation
convenience.
There are obvious examples where this makes sense -
“Given an administrator logs into the application”...
If the re-use of a step to achieve a certain sequence of
user/test behaviour does not break the readability or
logical flow of the BDD scenario, then it’s ok.
In your discovery sessions, the conversation and flow is
paramount. Document the natural language
requirements that are discussed.
Do not disrupt the ‘flow’ of your 3 amigos sessions by
hunting around for a step that you think already exists
just for its re-use.
People advocate step re-use for code maintainability’s
sake which is true, but implementing the page object
model will do exactly that anyhow.
Step re-use is also touted as an antidote to manageable
step definition files but not at the expense of best quality
readable scenarios.
Manage your Step
Definition files.
Understand that Step Definition files are unique
to tools like Cucumber. As such, there are
differing ways that they can be managed.
There is no one size fits all and this is probably
the least talked about aspect of BDD
implementation.
‘Technically it doesn’t matter how you name your
step definition files, or which step definitions you
put in a file. You could have one giant file
containing all your step definitions. However, we
recommend creating a separate file for each
domain concept.’
Common Practices
Link them with a parent feature
Manage them by maximum size
and create new Step Defs when
needed
Organise them by application
web page or mobile screen
Organise them by Given, When,
Then
Organise them by user and
application behaviour type -
navigating, verifying etc
Combine the Page
Object Model with the
Step Definitions.
This helps to keep step
definitions themselves
readable.
If re-usability of step definitions
is a team aspiration, this will
aid that.
Code maintenance then
resides at a single page class
and method level rather than
repeating common application
interactions present in multiple
steps.
Use of Cucumber
Example tables to
data drive your tests.
Focus on Test
independence.
Only parameterise
that which needs to be
parameterised.
Adding too many examples with too many
fields has the same effect as having too
many Scenario Steps. It reduces readability
and no-one is completely sure of what is
being proven.
Features, Scenarios,
Examples and Multi
Threaded test
automation.
Most BDD supporting test automation frameworks with multi-threaded test execution
enabled, will split the workload at the feature level. Why do we care?
For an optimised test execution runtime and an even load across threads, as much as is
practical without breaking your Feature/Scenario integrity, you should:
- Try and keep matching numbers of Scenarios across your Feature files.
- Try and keep balanced use of Scenario Outlines with Examples across your Feature files
- Otherwise you will find you have 1 or 2 slow, long running threads with an excessive
automation workload.
Do not use nested
‘steps within steps’ in
Cucumber.
Given /I complete an Amazon checkout/ do
steps %{
Given an unregistered user is on the Amazon UK website
When they search for a product
And add it to cart
Then they are able to complete a successful checkout
}
● Horrific for
troubleshooting a failed
test
● Was only ever about
automation copy and
paste convenience and
never about the BDD
requirements discovery
● Even the architects of
Cucumber later claimed
they wish they had never
enabled it
Use of Hooks - Before,
BeforeAll, After and
AfterAll.
BeforeAll - before every test to
be run
Before - before any single test
using a specified tag
AfterAll - after every test to be
run
After - after any single test
using a specified tag
Before/BeforeAll - Useful for
providing a clean, known
starting state for tests
After/AfterAll - Useful for
‘tearing down’ after tests and
keeping your test
environments clean and
performant
Use of tags to include
and exclude scenarios
for testing, linking to
requirements ids and
denoting risk and
criticality.
JIRA Req ref
After Hook
Priority for Run
Living
documentation
and
requirements
traceability.
Use a test reporting format that
incorporates the Features and
Scenarios.
Ensure your tests
provide a service to
you as the customer.
Your supporting automated tests have a
job to do and they must be fit for
purpose.
Fix them or retire them.
Retire, but don’t remove redundant
Features and Scenarios.
If called upon right now, could you…
1. Execute a critical set of automated
regression tests?
2. With consistent performance?
3. With quick, clear reporting?
4. With failure diagnostics?
…so that you could advise a Delivery
Team Go/No Go meeting whether or not
to release to production in an hour.
Test your readiness now!!
Ensure your testing
team provides a
service to your
customers.
Test your BDD
Scenarios themselves.
Use the Requirements
Testing Checks.
Review and Test your Requirements
Is it complete?
Don’t add placeholders to your feature and scenario
repository.
Is it ambiguous?
Do the Product Owner, Developer and Tester all
understand what’s required?
Is it singular?
Avoid the ‘twinning’ and ‘cross pollination’ of scenarios
with multiple requirements. Single requirement, single
scenario.
Is it testable?
Does it document clear and measurable outcomes for
success?
Is it deliverable?
If everything above is true, consider your requirement
and your scenario deliverable!
Recommended
Reading.
Find us at
testevolve.com | testevolve.github.io
Desktop & Mobile Browser | API | Native Apps | X Browser - X Device | Database | Desktop | Visual Checks | Accessibility | Integrations
- Browserstack, Kobiton, Saucelabs, Percy, Applitools, Perfecto |
FREE 90 Day Evaluation - testevolve.com/try
info@testevolve.com | james.readhead@testevolve.com
Search for

More Related Content

What's hot

AWS와 함께 하는 Unity 게임 배포 및 운영 전략 - AWS Summit Seoul 2017
AWS와 함께 하는 Unity 게임 배포 및 운영 전략 - AWS Summit Seoul 2017AWS와 함께 하는 Unity 게임 배포 및 운영 전략 - AWS Summit Seoul 2017
AWS와 함께 하는 Unity 게임 배포 및 운영 전략 - AWS Summit Seoul 2017Amazon Web Services Korea
 
AWS Monitoring & Logging
AWS Monitoring & LoggingAWS Monitoring & Logging
AWS Monitoring & LoggingJason Poley
 
Flutter for web
Flutter for web Flutter for web
Flutter for web rihannakedy
 
Spring cloud for microservices architecture
Spring cloud for microservices architectureSpring cloud for microservices architecture
Spring cloud for microservices architectureIgor Khotin
 
Logic Apps reuse with microservices design
Logic Apps reuse with microservices designLogic Apps reuse with microservices design
Logic Apps reuse with microservices designBizTalk360
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven DesignRyan Riley
 
Megaport Enabled AWS Direct Connect
Megaport Enabled AWS Direct ConnectMegaport Enabled AWS Direct Connect
Megaport Enabled AWS Direct ConnectDavid McCullough
 
REST Easy with Django-Rest-Framework
REST Easy with Django-Rest-FrameworkREST Easy with Django-Rest-Framework
REST Easy with Django-Rest-FrameworkMarcel Chastain
 
Firebase on Android: The Big Picture
Firebase on Android: The Big PictureFirebase on Android: The Big Picture
Firebase on Android: The Big PictureSriyank Siddhartha
 
Low level design template (1)
Low level design template (1)Low level design template (1)
Low level design template (1)anosha jamshed
 
Automating your AWS Security Operations
Automating your AWS Security OperationsAutomating your AWS Security Operations
Automating your AWS Security OperationsAmazon Web Services
 
Inside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjectsInside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjectsHansol Lee
 
Intro to AWS: EC2 & Compute Services
Intro to AWS: EC2 & Compute ServicesIntro to AWS: EC2 & Compute Services
Intro to AWS: EC2 & Compute ServicesAmazon Web Services
 

What's hot (20)

AWS와 함께 하는 Unity 게임 배포 및 운영 전략 - AWS Summit Seoul 2017
AWS와 함께 하는 Unity 게임 배포 및 운영 전략 - AWS Summit Seoul 2017AWS와 함께 하는 Unity 게임 배포 및 운영 전략 - AWS Summit Seoul 2017
AWS와 함께 하는 Unity 게임 배포 및 운영 전략 - AWS Summit Seoul 2017
 
AWS Monitoring & Logging
AWS Monitoring & LoggingAWS Monitoring & Logging
AWS Monitoring & Logging
 
Progressive Web App
Progressive Web AppProgressive Web App
Progressive Web App
 
Flutter for web
Flutter for web Flutter for web
Flutter for web
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
Hld and lld
Hld and lldHld and lld
Hld and lld
 
Spring cloud for microservices architecture
Spring cloud for microservices architectureSpring cloud for microservices architecture
Spring cloud for microservices architecture
 
Logic Apps reuse with microservices design
Logic Apps reuse with microservices designLogic Apps reuse with microservices design
Logic Apps reuse with microservices design
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
AWS EC2
AWS EC2AWS EC2
AWS EC2
 
Megaport Enabled AWS Direct Connect
Megaport Enabled AWS Direct ConnectMegaport Enabled AWS Direct Connect
Megaport Enabled AWS Direct Connect
 
React Workshop
React WorkshopReact Workshop
React Workshop
 
REST Easy with Django-Rest-Framework
REST Easy with Django-Rest-FrameworkREST Easy with Django-Rest-Framework
REST Easy with Django-Rest-Framework
 
Firebase on Android: The Big Picture
Firebase on Android: The Big PictureFirebase on Android: The Big Picture
Firebase on Android: The Big Picture
 
Low level design template (1)
Low level design template (1)Low level design template (1)
Low level design template (1)
 
Native vs. Hybrid Apps
Native vs. Hybrid AppsNative vs. Hybrid Apps
Native vs. Hybrid Apps
 
Flutter
FlutterFlutter
Flutter
 
Automating your AWS Security Operations
Automating your AWS Security OperationsAutomating your AWS Security Operations
Automating your AWS Security Operations
 
Inside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjectsInside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjects
 
Intro to AWS: EC2 & Compute Services
Intro to AWS: EC2 & Compute ServicesIntro to AWS: EC2 & Compute Services
Intro to AWS: EC2 & Compute Services
 

Similar to The complete guide to BDD + Cucumber Best Practices and Anti-Patterns.

Design your tests to behave - An introduction To BDD!
Design your tests to behave - An introduction To BDD!Design your tests to behave - An introduction To BDD!
Design your tests to behave - An introduction To BDD!Aparna A Gopalakrishnan
 
Build the Right Regression Suite with Behavior-Driven Testing
Build the Right Regression Suite with Behavior-Driven TestingBuild the Right Regression Suite with Behavior-Driven Testing
Build the Right Regression Suite with Behavior-Driven TestingTechWell
 
Scaling Agile - Agility Defined
Scaling Agile - Agility DefinedScaling Agile - Agility Defined
Scaling Agile - Agility DefinedVibhu Srinivasan
 
Xamariners - BDD + Mobile
Xamariners - BDD + MobileXamariners - BDD + Mobile
Xamariners - BDD + MobileXamariners
 
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...Scrum Bangalore
 
! Testing for agile teams
! Testing for agile teams! Testing for agile teams
! Testing for agile teamsDennis Popov
 
The Agile Readiness Assessment Tool Essay
The Agile Readiness Assessment Tool EssayThe Agile Readiness Assessment Tool Essay
The Agile Readiness Assessment Tool EssayHeidi Owens
 
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
 
Agile testingandautomation
Agile testingandautomationAgile testingandautomation
Agile testingandautomationjeisner
 
recapitulando: de métodos ágeis até lean startup
recapitulando: de métodos ágeis até lean startuprecapitulando: de métodos ágeis até lean startup
recapitulando: de métodos ágeis até lean startupPedro Axelrud
 
How to Best Develop a Product by PlateRate Founder
How to Best Develop a Product by PlateRate FounderHow to Best Develop a Product by PlateRate Founder
How to Best Develop a Product by PlateRate FounderProduct School
 
Effective User Story Writing
Effective User Story WritingEffective User Story Writing
Effective User Story WritingAhmed Misbah
 
Myths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven DevelopmentMyths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven DevelopmentPankaj Nakhat
 
Quality analysis pdf to study For your education
Quality analysis pdf to study For your educationQuality analysis pdf to study For your education
Quality analysis pdf to study For your educationShraddhatadmare1
 

Similar to The complete guide to BDD + Cucumber Best Practices and Anti-Patterns. (20)

Design your tests to behave - An introduction To BDD!
Design your tests to behave - An introduction To BDD!Design your tests to behave - An introduction To BDD!
Design your tests to behave - An introduction To BDD!
 
Build the Right Regression Suite with Behavior-Driven Testing
Build the Right Regression Suite with Behavior-Driven TestingBuild the Right Regression Suite with Behavior-Driven Testing
Build the Right Regression Suite with Behavior-Driven Testing
 
Scaling Agile - Agility Defined
Scaling Agile - Agility DefinedScaling Agile - Agility Defined
Scaling Agile - Agility Defined
 
Templates.pptx
Templates.pptxTemplates.pptx
Templates.pptx
 
Xamariners - BDD + Mobile
Xamariners - BDD + MobileXamariners - BDD + Mobile
Xamariners - BDD + Mobile
 
Agile case studies
Agile case studiesAgile case studies
Agile case studies
 
User Stories Lunch & Learn
User Stories Lunch & LearnUser Stories Lunch & Learn
User Stories Lunch & Learn
 
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...
 
! Testing for agile teams
! Testing for agile teams! Testing for agile teams
! Testing for agile teams
 
The Agile Readiness Assessment Tool Essay
The Agile Readiness Assessment Tool EssayThe Agile Readiness Assessment Tool Essay
The Agile Readiness Assessment Tool Essay
 
User Stories
User StoriesUser Stories
User Stories
 
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
 
Agile testingandautomation
Agile testingandautomationAgile testingandautomation
Agile testingandautomation
 
recapitulando: de métodos ágeis até lean startup
recapitulando: de métodos ágeis até lean startuprecapitulando: de métodos ágeis até lean startup
recapitulando: de métodos ágeis até lean startup
 
T&B_fin
T&B_finT&B_fin
T&B_fin
 
How to Best Develop a Product by PlateRate Founder
How to Best Develop a Product by PlateRate FounderHow to Best Develop a Product by PlateRate Founder
How to Best Develop a Product by PlateRate Founder
 
Effective User Story Writing
Effective User Story WritingEffective User Story Writing
Effective User Story Writing
 
ERP Genesis Digitek
ERP Genesis DigitekERP Genesis Digitek
ERP Genesis Digitek
 
Myths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven DevelopmentMyths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven Development
 
Quality analysis pdf to study For your education
Quality analysis pdf to study For your educationQuality analysis pdf to study For your education
Quality analysis pdf to study For your education
 

Recently uploaded

SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 

Recently uploaded (20)

SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 

The complete guide to BDD + Cucumber Best Practices and Anti-Patterns.

  • 1. The complete guide to BDD + Cucumber Best Practices and Anti-Patterns with Test Automation BDD and tools like Cucumber, when used correctly, should add significant value to your organisation’s project delivery, product quality and customer satisfaction. …when used correctly… And herein lies the problem. They are highly prone to unintentional misuse that quickly diminishes their value-add. More often than not, the process and the tools are used poorly and in a manner far from the intention of the teams that built them. In this webinar, we’ll take you through the complete guide of firmly accepted best practices to embrace and anti-patterns to avoid when starting to use these tools and processes in your organisation.
  • 2. Chair a collaborative 3-amigos requirements forum with your Product Owners, Developers and Testers. Collaborate and communicate. Discuss and Question the requirements. Explore the What ifs and the Edge Cases. Capture the agreed outcomes and desired behaviours in a BDD Scenario. Product Owners can outline a basic intent, Developers can lead the technical discussion and Testers can lead an exploration of the boundaries and the unexpected. Do not have Team Members write Features and Scenarios in isolation. Do not write BDD scenarios after you have already implemented a feature. BDD is first and foremost about a conversation. If you’re not conversing you are not ‘doing’ BDD.
  • 3. Focus on describing the end-to-end journey the customer is undertaking, not how they are executing it. Avoid combining multiple requirements. Bad Given an unregistered user is on the Amazon UK website When they click in the Search field And enter ‘Headphones’ And click search Then they see a Search Results page When they select a product Then they see a Product Details Page When they add quantity ‘2’ And click on ‘Add to cart’ Then they are able to complete a successful checkout ● Choose declarative over imperative ● Embrace singularity ● Anyone should be able to immediately understand the flow ● The steps in Ex1 should be contained in the Step Defs only ● Changes in UI flow will break scenarios Good Given an unregistered user is on the Amazon UK website When they search for a product And add it to cart Then they are able to complete a successful checkout Bad Given an unregistered user is on the Amazon UK website When they search for a product And add it to cart Then they are able to complete a successful checkout And they can then register as a new user
  • 4. Use your Given as a starting journey state, your When as a series of user actions and your Then as a verification point. ● Past, present and Future tense ● Background Steps ● Feature Narratives ● And + But in moderation ● 1st vs 3rd person Better - ‘Past, Present and Future’ OR ‘Present’ all the way and introducing Narratives and Background steps. Feature: UK Checkouts As a user I wish to checkout with a product I’ve chosen Background: Given an unregistered user went to the Amazon UK website Scenario: Successful Amazon UK Checkout When they search for a product And add it to cart Then they will be able to complete a successful checkout OK - Bad Tense usage Given I will go to the Amazon UK website When I searched for a product And added it to cart Then I can complete a successful checkout Use grammatically correct, concise, natural language with basic business process terminology as required.
  • 5. Positive and Negative behaviours. ● Capture what should happen as well as what shouldn’t ● How should the application fail gracefully in the event of an unexpected user behaviour? ● Which error messages should the customer see in which circumstances?
  • 6. If your working with a Spanish customer, use Spanish. Given a user is on the Amazon website When they search for a product And add it to their cart Then they can checkout successfully Dado que un usuario está en el sitio web de Amazon Cuando buscan un producto Y añádelo a su carrito. Entonces pueden pagar con éxito ● Watch the buy-in of your customer and the shared collaboration with them skyrocket if you can embrace a local language ● In your requirements management tool, for example JIRA, why not capture both versions? 1 for the customer and 1 for the delivery team.
  • 7. Don’t force the re-use of scenario steps for automation convenience. There are obvious examples where this makes sense - “Given an administrator logs into the application”... If the re-use of a step to achieve a certain sequence of user/test behaviour does not break the readability or logical flow of the BDD scenario, then it’s ok. In your discovery sessions, the conversation and flow is paramount. Document the natural language requirements that are discussed. Do not disrupt the ‘flow’ of your 3 amigos sessions by hunting around for a step that you think already exists just for its re-use. People advocate step re-use for code maintainability’s sake which is true, but implementing the page object model will do exactly that anyhow. Step re-use is also touted as an antidote to manageable step definition files but not at the expense of best quality readable scenarios.
  • 8. Manage your Step Definition files. Understand that Step Definition files are unique to tools like Cucumber. As such, there are differing ways that they can be managed. There is no one size fits all and this is probably the least talked about aspect of BDD implementation. ‘Technically it doesn’t matter how you name your step definition files, or which step definitions you put in a file. You could have one giant file containing all your step definitions. However, we recommend creating a separate file for each domain concept.’ Common Practices Link them with a parent feature Manage them by maximum size and create new Step Defs when needed Organise them by application web page or mobile screen Organise them by Given, When, Then Organise them by user and application behaviour type - navigating, verifying etc
  • 9. Combine the Page Object Model with the Step Definitions. This helps to keep step definitions themselves readable. If re-usability of step definitions is a team aspiration, this will aid that. Code maintenance then resides at a single page class and method level rather than repeating common application interactions present in multiple steps.
  • 10. Use of Cucumber Example tables to data drive your tests. Focus on Test independence. Only parameterise that which needs to be parameterised. Adding too many examples with too many fields has the same effect as having too many Scenario Steps. It reduces readability and no-one is completely sure of what is being proven.
  • 11. Features, Scenarios, Examples and Multi Threaded test automation. Most BDD supporting test automation frameworks with multi-threaded test execution enabled, will split the workload at the feature level. Why do we care? For an optimised test execution runtime and an even load across threads, as much as is practical without breaking your Feature/Scenario integrity, you should: - Try and keep matching numbers of Scenarios across your Feature files. - Try and keep balanced use of Scenario Outlines with Examples across your Feature files - Otherwise you will find you have 1 or 2 slow, long running threads with an excessive automation workload.
  • 12. Do not use nested ‘steps within steps’ in Cucumber. Given /I complete an Amazon checkout/ do steps %{ Given an unregistered user is on the Amazon UK website When they search for a product And add it to cart Then they are able to complete a successful checkout } ● Horrific for troubleshooting a failed test ● Was only ever about automation copy and paste convenience and never about the BDD requirements discovery ● Even the architects of Cucumber later claimed they wish they had never enabled it
  • 13. Use of Hooks - Before, BeforeAll, After and AfterAll. BeforeAll - before every test to be run Before - before any single test using a specified tag AfterAll - after every test to be run After - after any single test using a specified tag Before/BeforeAll - Useful for providing a clean, known starting state for tests After/AfterAll - Useful for ‘tearing down’ after tests and keeping your test environments clean and performant
  • 14. Use of tags to include and exclude scenarios for testing, linking to requirements ids and denoting risk and criticality. JIRA Req ref After Hook Priority for Run
  • 15. Living documentation and requirements traceability. Use a test reporting format that incorporates the Features and Scenarios.
  • 16. Ensure your tests provide a service to you as the customer. Your supporting automated tests have a job to do and they must be fit for purpose. Fix them or retire them. Retire, but don’t remove redundant Features and Scenarios. If called upon right now, could you… 1. Execute a critical set of automated regression tests? 2. With consistent performance? 3. With quick, clear reporting? 4. With failure diagnostics? …so that you could advise a Delivery Team Go/No Go meeting whether or not to release to production in an hour. Test your readiness now!! Ensure your testing team provides a service to your customers.
  • 17. Test your BDD Scenarios themselves. Use the Requirements Testing Checks. Review and Test your Requirements Is it complete? Don’t add placeholders to your feature and scenario repository. Is it ambiguous? Do the Product Owner, Developer and Tester all understand what’s required? Is it singular? Avoid the ‘twinning’ and ‘cross pollination’ of scenarios with multiple requirements. Single requirement, single scenario. Is it testable? Does it document clear and measurable outcomes for success? Is it deliverable? If everything above is true, consider your requirement and your scenario deliverable!
  • 19. Find us at testevolve.com | testevolve.github.io Desktop & Mobile Browser | API | Native Apps | X Browser - X Device | Database | Desktop | Visual Checks | Accessibility | Integrations - Browserstack, Kobiton, Saucelabs, Percy, Applitools, Perfecto | FREE 90 Day Evaluation - testevolve.com/try info@testevolve.com | james.readhead@testevolve.com Search for