SlideShare a Scribd company logo
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
Ad

More Related Content

What's hot (20)

Cross-Browser-Testing with Protractor & Browserstack
Cross-Browser-Testing with Protractor & BrowserstackCross-Browser-Testing with Protractor & Browserstack
Cross-Browser-Testing with Protractor & Browserstack
Leo Lindhorst
 
Build MLOps System on AWS
Build MLOps System on AWS Build MLOps System on AWS
Build MLOps System on AWS
Yunrui Li
 
UI Testing Automation
UI Testing AutomationUI Testing Automation
UI Testing Automation
AgileEngine
 
Load and performance testing
Load and performance testingLoad and performance testing
Load and performance testing
Qualitest
 
Api testing
Api testingApi testing
Api testing
Keshav Kashyap
 
[Open southcode] ios testing with appium
[Open southcode] ios testing with appium[Open southcode] ios testing with appium
[Open southcode] ios testing with appium
Estefanía Fernández Muñoz
 
POSTMAN.pptx
POSTMAN.pptxPOSTMAN.pptx
POSTMAN.pptx
RamaKrishna970827
 
E commerce Testing
E commerce TestingE commerce Testing
E commerce Testing
Atul Pant
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
Sauce Labs
 
Postman.ppt
Postman.pptPostman.ppt
Postman.ppt
ParrotBAD
 
Unit & integration testing
Unit & integration testingUnit & integration testing
Unit & integration testing
Pavlo Hodysh
 
So you think you can write a test case
So you think you can write a test caseSo you think you can write a test case
So you think you can write a test case
Srilu Balla
 
ISTQB-FL.pptx
ISTQB-FL.pptxISTQB-FL.pptx
ISTQB-FL.pptx
Arshad QA
 
Performance Testing
Performance TestingPerformance Testing
Performance Testing
sharmaparish
 
Data Driven Testing
Data Driven TestingData Driven Testing
Data Driven Testing
Maveryx
 
What is Software Testing | Edureka
What is Software Testing | EdurekaWhat is Software Testing | Edureka
What is Software Testing | Edureka
Edureka!
 
Postman: An Introduction for Developers
Postman: An Introduction for DevelopersPostman: An Introduction for Developers
Postman: An Introduction for Developers
Postman
 
How to start performance testing project
How to start performance testing projectHow to start performance testing project
How to start performance testing project
NaveenKumar Namachivayam
 
Writing Test Cases in Agile
Writing Test Cases in AgileWriting Test Cases in Agile
Writing Test Cases in Agile
Saroj Singh
 
Karate DSL
Karate DSLKarate DSL
Karate DSL
anil borse
 
Cross-Browser-Testing with Protractor & Browserstack
Cross-Browser-Testing with Protractor & BrowserstackCross-Browser-Testing with Protractor & Browserstack
Cross-Browser-Testing with Protractor & Browserstack
Leo Lindhorst
 
Build MLOps System on AWS
Build MLOps System on AWS Build MLOps System on AWS
Build MLOps System on AWS
Yunrui Li
 
UI Testing Automation
UI Testing AutomationUI Testing Automation
UI Testing Automation
AgileEngine
 
Load and performance testing
Load and performance testingLoad and performance testing
Load and performance testing
Qualitest
 
E commerce Testing
E commerce TestingE commerce Testing
E commerce Testing
Atul Pant
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
Sauce Labs
 
Unit & integration testing
Unit & integration testingUnit & integration testing
Unit & integration testing
Pavlo Hodysh
 
So you think you can write a test case
So you think you can write a test caseSo you think you can write a test case
So you think you can write a test case
Srilu Balla
 
ISTQB-FL.pptx
ISTQB-FL.pptxISTQB-FL.pptx
ISTQB-FL.pptx
Arshad QA
 
Performance Testing
Performance TestingPerformance Testing
Performance Testing
sharmaparish
 
Data Driven Testing
Data Driven TestingData Driven Testing
Data Driven Testing
Maveryx
 
What is Software Testing | Edureka
What is Software Testing | EdurekaWhat is Software Testing | Edureka
What is Software Testing | Edureka
Edureka!
 
Postman: An Introduction for Developers
Postman: An Introduction for DevelopersPostman: An Introduction for Developers
Postman: An Introduction for Developers
Postman
 
Writing Test Cases in Agile
Writing Test Cases in AgileWriting Test Cases in Agile
Writing Test Cases in Agile
Saroj Singh
 

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!
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 Testing
TechWell
 
Scaling Agile - Agility Defined
Scaling Agile - Agility DefinedScaling Agile - Agility Defined
Scaling Agile - Agility Defined
Vibhu Srinivasan
 
Templates.pptx
Templates.pptxTemplates.pptx
Templates.pptx
ssuser994d18
 
Xamariners - BDD + Mobile
Xamariners - BDD + MobileXamariners - BDD + Mobile
Xamariners - BDD + Mobile
Xamariners
 
Agile case studies
Agile case studiesAgile case studies
Agile case studies
Sébastien Donné
 
User Stories Lunch & Learn
User Stories Lunch & LearnUser Stories Lunch & Learn
User Stories Lunch & Learn
Christopher Say Go
 
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 teams
Dennis Popov
 
The Agile Readiness Assessment Tool Essay
The Agile Readiness Assessment Tool EssayThe Agile Readiness Assessment Tool Essay
The Agile Readiness Assessment Tool Essay
Heidi Owens
 
User Stories
User StoriesUser Stories
User Stories
scornelius
 
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
Product School
 
Agile testingandautomation
Agile testingandautomationAgile testingandautomation
Agile testingandautomation
jeisner
 
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
Pedro Axelrud
 
T&B_fin
T&B_finT&B_fin
T&B_fin
tadams76
 
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
Product School
 
Effective User Story Writing
Effective User Story WritingEffective User Story Writing
Effective User Story Writing
Ahmed Misbah
 
ERP Genesis Digitek
ERP Genesis DigitekERP Genesis Digitek
ERP Genesis Digitek
RushikeshParekh1
 
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
Pankaj 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 education
Shraddhatadmare1
 
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 Testing
TechWell
 
Scaling Agile - Agility Defined
Scaling Agile - Agility DefinedScaling Agile - Agility Defined
Scaling Agile - Agility Defined
Vibhu Srinivasan
 
Xamariners - BDD + Mobile
Xamariners - BDD + MobileXamariners - BDD + Mobile
Xamariners - BDD + Mobile
Xamariners
 
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 teams
Dennis Popov
 
The Agile Readiness Assessment Tool Essay
The Agile Readiness Assessment Tool EssayThe Agile Readiness Assessment Tool Essay
The Agile Readiness Assessment Tool Essay
Heidi 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 Manager
Product School
 
Agile testingandautomation
Agile testingandautomationAgile testingandautomation
Agile testingandautomation
jeisner
 
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
Pedro 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 Founder
Product School
 
Effective User Story Writing
Effective User Story WritingEffective User Story Writing
Effective User Story Writing
Ahmed 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 Development
Pankaj 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 education
Shraddhatadmare1
 
Ad

Recently uploaded (20)

What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Ad

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 [email protected] | [email protected] Search for