SlideShare a Scribd company logo
Your Automated Execution Does Not
Have to be Flaky
Eurostar Webinars Feb 2018
Alan Richardson
www.eviltester.com/flaky
www.compendiumdev.co.uk
@eviltester
@EvilTester 1
Have you experienced flaky test automation? In this webinar, Alan
Richardson plans to convince you that you haven't. Instead you
have experienced the result of not resolving the causes of
Intermittent execution. Alan will explore some common causes and
solutions of intermittent behaviour. Why? So you never say the
phrase, "flaky tests", ever again.
@EvilTester 2
Flaky Test Automation is Normal
@EvilTester 3
Flaky Test Automation is Normal
Because we have normalized Flaky Test
Automation
"Our Tests are Flaky"
"Some tests fail Randomly"
@EvilTester 4
"There is nothing so absurd that it has
not been said by some philosopher."
Cicero, On Divination, Book II chapter LVIII, section 119 ﴾44 BC﴿
"Truth happens to an idea. It becomes
true, is made true by events."
William James, Lecture VI, Pragmatism's Conception of Truth,
Pragmatism: A New Name for Some Old Ways of Thinking ﴾1907﴿
@EvilTester 5
How to Normalize Flaky Test Automation
We all know these Test Automation Truths
"GUI Automation is Flaky"
"We have to live with 'flakiness'"
"We shouldn't automate at the GUI"
"We can only remove flakiness under the GUI"
"Flaky Tests" blames the tests. Not good enough.
@EvilTester 6
It isn't even the "Tests"
We don't automate Tests
We automate the execution of steps in a workflow or process
We automate the execution of a System
We add condition assertions during that execution
We don't have flaky Tests ‐ we have automated execution that fails.
Sometimes on the steps, sometimes on the assertions.
@EvilTester 7
'Flakiness' does not reside at a 'level'
I have seen 'flakiness'
in Unit Tests
in API Tests
in Integration Tests
in GUI Tests
@EvilTester 8
It is too easy to say 'flaky'
and then blame 'GUI execution'
and then blame 'the tool'
Living with flakiness is a choice.
Choose a different approach.
@EvilTester 9
I am not the only person saying this.
see references at the end and name drops throughout
try to cover something different in this talk
@EvilTester 10
"We designed that flakiness. We are allowing that
to happen. We engineered it to be that way. And
its our fault that that exists."
Richard Bradshaw, "Your Tests aren't Flaky, You Are!" Selenium
Conference 2017
https://www.youtube.com/watch?v=XnkWkrbzMh0
@EvilTester 11
Take it more seriously. Describe it
differently.
Intermittent
Occurring at irregular intervals; not continuous or steady.
https://en.oxforddictionaries.com/definition/intermittent
@EvilTester 12
Take it more seriously. Describe it
differently.
Nondeterministic Algorithm
"a nondeterministic algorithm is an algorithm that, even for the
same input, can exhibit different behaviors on different runs"
https://en.wikipedia.org/wiki/Nondeterministic_algorithm
@EvilTester 13
Flaky is not serious enough.
We do not want to use nondeterministic
algorithms for continuous assertions that we are
relying on
@EvilTester 14
Your Test Automation is not Flaky
Your automated execution fails intermittently
@EvilTester 15
Don't Blame Tests. Look For Root Causes.
watch Alister Scott's GTAC 2015 talk
@EvilTester 16
I have removed 'flakiness'
from Unit Tests
from API Tests
from Integration Tests
from GUI Tests
Automated execution does not have to fail intermittently.
@EvilTester 17
How to remove Intermittent Failure from
your Automated Execution
1. Care
2. Investigate
3. Do something about it
@EvilTester 18
How to remove Intermittent Failure from
your Automated Execution
1. Decide Intermittent Failure is unacceptable
2. Investigate the cause of Intermittent Failure
3. Mitigate
Remove the cause
actually fix it
Implement a retry strategy
might obscure bugs
Accept Intermittent Results
might provide hints at solutions
@EvilTester 19
Take it seriously
We write Automate Assertion checking because we care that those
assertions are true for each build of the system.
Determinism is important.
@EvilTester 20
High Level Grouping of Common Causes
of Intermittency
Synchronisation ‐ lack of or poor
Parallel Execution ‐ interference
Long Running Tests ‐ too long, too risky
Automatability ‐ hard to automate system
Tools ‐ inappropriate or out of date
State Preconditions ‐ not controlled
Assertions ‐ wrong or incorrect assumptions
Data ‐ not controlled
see also Richard Bradshaw and Mark Winteringham "SACRED"
Mnemonic.
@EvilTester 21
Will cover Top 3 for each Grouping
@EvilTester 22
Top 3 Common Causes ‐ Synchronisation
None
Time Based Synchronisation
Incorrect App State Synchronisation
@EvilTester 23
Common Solutions ‐ Synchronisation
Synchronise on States
do not rely on framework Synchronisation
Multiple Intermediate States
Consider Latency
Synchronise in Abstractions not the  @Test methods
unless  @Test specific
@EvilTester 24
Top 3 Common Causes ‐ Parallel
Execution
Framework not thread safe
Tests Interfere
Shared Test Environment
@EvilTester 25
Common Solutions ‐ Parallel Execution
Independent environments
Independent Data
Separate Suites rather than threaded execution
Create Threadsafe, reusable code
Create reusable library abstractions rather than
Frameworks
Avoid 'static' singleton objects
@EvilTester 26
Top 3 Common Causes ‐ Long Running
Tests
Sequential rather than Model Based
not delineating between: preconditions, process, assertion
components tests in flow rather than isolation
@EvilTester 27
Common Solutions ‐ Long Running Tests
Understand that more actions == more risk
Synchronise prior to each step
Consider Model Based Testing
Create component test and automated execution playgrounds
Minimum assertions
@EvilTester 28
Top 3 Common Causes ‐ Automatability,
Automatizability
Not Testability:
Application has non‐deterministic behaviour
Hard to Synchronise
Application fails non‐deterministically in live
@EvilTester 29
Common Solutions ‐ Automatability,
Automatizability
Build apps that can be automated
Non‐Deterministic apps need step retry strategies rather than
test retry strategies
@EvilTester 30
Top 3 Common Causes ‐ Tools
Out of Date
Inappropriate
Local Tool Infrastructure
@EvilTester 31
Common Solutions ‐ Tools
Use the right tool for the job
Keep your tooling environment controlled and up to date
Change your approach to take latency into account
process on server return results
return source, process on execution client
@EvilTester 32
Top 3 Common Causes ‐ State
Preconditions
Not Checking State Preconditions at start of test
Not controlling state preconditions prior to test
Precondition setup using same tool
@EvilTester 33
Common Solutions ‐ State Preconditions
control data
precondition state setup ‐ whatever works
http, db, api ‐ 'hack it in'
avoid dependencies between execution unless a long running
test
@EvilTester 34
Top 3 Common Causes ‐ Assumptions
Encoded in Assertions
Assert on an Ordered Set
Assert on Uncontrolled Data
Assertion Tolerences
@EvilTester 35
Common Solutions ‐ Assumptions
Encoded in Assertions
Logging so you can interrogate failure afterwards
Ability to re‐run tests with same data and setup
@EvilTester 36
Top 3 Common Causes ‐ Data
Missing Data
Externally controlled data
Uncontrolled Data
@EvilTester 37
Common Solutions ‐ Data
Create data for each test
Avoid test dependencies
Avoid re‐using data between tests
Check data as a precondition
Data synchronisation on all precondition data
@EvilTester 38
Summary
Your Test Execution is not 'flaky', it is failing intermittently
It is possible to remove intermittent failures, even when
automating through a GUI
Commons solutions: synchronisation, data control,
environmental isolation
@EvilTester 39
Other talks to watch
Alister Scott, GTAC 2015: Your Tests Aren't Flaky
https://www.youtube.com/watch?v=hmk1h40shaE
Richard Bradshaw, "Your Tests aren't Flaky, You Are!" Selenium
Conference 2017
https://www.youtube.com/watch?v=XnkWkrbzMh0
@EvilTester 40
Other talks to watch
Craig Schwarzwald, SAY GOODBYE TO THE “F” WORD … FLAKY
NO MORE!
https://www.youtube.com/watch?v=2K2M7s_Ups0
Mark Winteringham ‐ REST APIs and WebDriver: In Perfect
Harmony
https://www.youtube.com/watch?v=ugAlCZBMOvM
Search also for: Flaky Selenium, Flaky Automation, Flaky Test
Automation
@EvilTester 41
End
Alan Richardson www.compendiumdev.co.uk
Linkedin ‐ @eviltester
Twitter ‐ @eviltester
Instagram ‐ @eviltester
Facebook ‐ @eviltester
Youtube ‐ EvilTesterVideos
Pinterest ‐ @eviltester
Github ‐ @eviltester
Slideshare ‐ @eviltester
@EvilTester 42
BIO
Alan is a Software Development and Testing Coach/Consultant who
enjoys testing at a technical level using techniques from
psychotherapy and computer science. In his spare time Alan is
currently programming a Twitter client called ChatterScan, and
multi‐user text adventure game. Alan is the author of the books
"Dear Evil Tester", "Java For Testers" and "Automating and Testing a
REST API". Alan's main website is compendiumdev.co.uk and he
blogs at blog.eviltester.com
@EvilTester 43

More Related Content

What's hot (20)

PDF
Effective Software Testing for Modern Software Development
Alan Richardson
 
PDF
Joy of Coding Conference 2019 slides - Alan Richardson
Alan Richardson
 
PDF
Add More Security To Your Testing and Automating - Saucecon 2021
Alan Richardson
 
PDF
Automating Strategically or Tactically when Testing
Alan Richardson
 
PDF
What is Regression Testing?
Alan Richardson
 
PDF
Automating Pragmatically - Testival 20190604
Alan Richardson
 
PPTX
Risk Mitigation Using Exploratory and Technical Testing - QASymphony Webinar ...
Alan Richardson
 
PDF
Automating to Augment Testing
Alan Richardson
 
PDF
Technical and Testing Challenges: Using the "Protect The Square" Game
Alan Richardson
 
PDF
Practical Test Automation Deep Dive
Alan Richardson
 
PDF
Shift left-testing
Alan Richardson
 
ODP
How to Improve Your Technical Test Ability - AADays 2015 Keynote
Alan Richardson
 
PDF
If you want to automate, you learn to code
Alan Richardson
 
PDF
Confessions of an Accidental Security Tester
Alan Richardson
 
PDF
Re-thinking Test Automation and Test Process Modelling (in pictures)
Alan Richardson
 
PDF
TestIstanbul May 2013 Keynote Experiences With Exploratory Testing
Alan Richardson
 
PDF
Technology Based Testing
Alan Richardson
 
PDF
Black Ops Testing Workshop from Agile Testing Days 2014
Alan Richardson
 
PPTX
Automation vs. intelligence - "follow me if you want to live"
Viktor Slavchev
 
PDF
Technical Testing Webinar
Alan Richardson
 
Effective Software Testing for Modern Software Development
Alan Richardson
 
Joy of Coding Conference 2019 slides - Alan Richardson
Alan Richardson
 
Add More Security To Your Testing and Automating - Saucecon 2021
Alan Richardson
 
Automating Strategically or Tactically when Testing
Alan Richardson
 
What is Regression Testing?
Alan Richardson
 
Automating Pragmatically - Testival 20190604
Alan Richardson
 
Risk Mitigation Using Exploratory and Technical Testing - QASymphony Webinar ...
Alan Richardson
 
Automating to Augment Testing
Alan Richardson
 
Technical and Testing Challenges: Using the "Protect The Square" Game
Alan Richardson
 
Practical Test Automation Deep Dive
Alan Richardson
 
Shift left-testing
Alan Richardson
 
How to Improve Your Technical Test Ability - AADays 2015 Keynote
Alan Richardson
 
If you want to automate, you learn to code
Alan Richardson
 
Confessions of an Accidental Security Tester
Alan Richardson
 
Re-thinking Test Automation and Test Process Modelling (in pictures)
Alan Richardson
 
TestIstanbul May 2013 Keynote Experiences With Exploratory Testing
Alan Richardson
 
Technology Based Testing
Alan Richardson
 
Black Ops Testing Workshop from Agile Testing Days 2014
Alan Richardson
 
Automation vs. intelligence - "follow me if you want to live"
Viktor Slavchev
 
Technical Testing Webinar
Alan Richardson
 

Similar to Your Automated Execution Does Not Have to be Flaky (20)

PDF
SFSCON23 - Juri Solovjov - Flaky tests – how to deal with them
South Tyrol Free Software Conference
 
PDF
Solving Flaky Automated Tests Using Machine Learning
James Farrier
 
PDF
Shifting Testing Left - The Pain Points and Solutions
James Farrier
 
PPTX
Test Design + Environment Management: Scaling UI Automation for Agile
SmartBear
 
PDF
Reading Notes of The Art Of Unit Test Ch7
Benjamin Fan
 
PDF
Lessons Learned When Automating
Alan Richardson
 
PDF
Does Refactoring of Test Smells Induce Fixing Flaky Tests?
Fabio Palomba
 
PDF
The Death of Flaky Tests by Dave Haeffner
Sauce Labs
 
PPTX
SANTIAGO STAREAST 2016
Dionny Santiago
 
PDF
How to Make Your UI Tests Stable, Scalable, and Maintainable
SmartBear
 
PPTX
Best practices for test automation
David Tzemach
 
PDF
Building The Blocks of Trust in Automation by Sneha Viswalingam
Sauce Labs
 
PDF
Change Tyres In A Moving Car - Make Functional Test Automation Effective Keynote
Anand Bagmar
 
PPTX
Google, quality and you
nelinger
 
PPTX
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
TEST Huddle
 
PDF
Abstraction Layers Test Management Summit Faciliated Session 2014
Alan Richardson
 
PPTX
Real Testing Scenario Strategy - The Role of Exploratory Testing
Adam Sandman
 
PPTX
From Manual To Automated Software Testing - A Webinar Presentation
Inflectra
 
PDF
Why Software Test Performance Matters
Solano Labs
 
PPTX
Presentation delex
Alexander Pushkarev
 
SFSCON23 - Juri Solovjov - Flaky tests – how to deal with them
South Tyrol Free Software Conference
 
Solving Flaky Automated Tests Using Machine Learning
James Farrier
 
Shifting Testing Left - The Pain Points and Solutions
James Farrier
 
Test Design + Environment Management: Scaling UI Automation for Agile
SmartBear
 
Reading Notes of The Art Of Unit Test Ch7
Benjamin Fan
 
Lessons Learned When Automating
Alan Richardson
 
Does Refactoring of Test Smells Induce Fixing Flaky Tests?
Fabio Palomba
 
The Death of Flaky Tests by Dave Haeffner
Sauce Labs
 
SANTIAGO STAREAST 2016
Dionny Santiago
 
How to Make Your UI Tests Stable, Scalable, and Maintainable
SmartBear
 
Best practices for test automation
David Tzemach
 
Building The Blocks of Trust in Automation by Sneha Viswalingam
Sauce Labs
 
Change Tyres In A Moving Car - Make Functional Test Automation Effective Keynote
Anand Bagmar
 
Google, quality and you
nelinger
 
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
TEST Huddle
 
Abstraction Layers Test Management Summit Faciliated Session 2014
Alan Richardson
 
Real Testing Scenario Strategy - The Role of Exploratory Testing
Adam Sandman
 
From Manual To Automated Software Testing - A Webinar Presentation
Inflectra
 
Why Software Test Performance Matters
Solano Labs
 
Presentation delex
Alexander Pushkarev
 
Ad

More from Alan Richardson (14)

PDF
Open source tools - Test Management Summit - 2009
Alan Richardson
 
PDF
Automating Tactically vs Strategically SauceCon 2020
Alan Richardson
 
PDF
Programming katas for Software Testers - CounterStrings
Alan Richardson
 
PDF
About Consultant Alan Richardson Compendium Developments Evil Tester
Alan Richardson
 
PDF
Automating and Testing a REST API
Alan Richardson
 
PDF
TDD - Test Driven Development - Java JUnit FizzBuzz
Alan Richardson
 
PDF
What is Testability vs Automatability? How to improve your Software Testing.
Alan Richardson
 
PDF
What is Agile Testing? A MindMap
Alan Richardson
 
PDF
Evil Tester's Guide to Agile Testing
Alan Richardson
 
PDF
The Evil Tester Show - Episode 001 Halloween 2017
Alan Richardson
 
PDF
Simple ways to add and work with a `.jar` file in your local maven setup
Alan Richardson
 
PDF
Learning in Public - A How to Speak in Public Workshop
Alan Richardson
 
PDF
How to Practise to Remove Fear of Public Speaking
Alan Richardson
 
PDF
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
Alan Richardson
 
Open source tools - Test Management Summit - 2009
Alan Richardson
 
Automating Tactically vs Strategically SauceCon 2020
Alan Richardson
 
Programming katas for Software Testers - CounterStrings
Alan Richardson
 
About Consultant Alan Richardson Compendium Developments Evil Tester
Alan Richardson
 
Automating and Testing a REST API
Alan Richardson
 
TDD - Test Driven Development - Java JUnit FizzBuzz
Alan Richardson
 
What is Testability vs Automatability? How to improve your Software Testing.
Alan Richardson
 
What is Agile Testing? A MindMap
Alan Richardson
 
Evil Tester's Guide to Agile Testing
Alan Richardson
 
The Evil Tester Show - Episode 001 Halloween 2017
Alan Richardson
 
Simple ways to add and work with a `.jar` file in your local maven setup
Alan Richardson
 
Learning in Public - A How to Speak in Public Workshop
Alan Richardson
 
How to Practise to Remove Fear of Public Speaking
Alan Richardson
 
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
Alan Richardson
 
Ad

Recently uploaded (20)

PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 

Your Automated Execution Does Not Have to be Flaky

  • 1. Your Automated Execution Does Not Have to be Flaky Eurostar Webinars Feb 2018 Alan Richardson www.eviltester.com/flaky www.compendiumdev.co.uk @eviltester @EvilTester 1
  • 2. Have you experienced flaky test automation? In this webinar, Alan Richardson plans to convince you that you haven't. Instead you have experienced the result of not resolving the causes of Intermittent execution. Alan will explore some common causes and solutions of intermittent behaviour. Why? So you never say the phrase, "flaky tests", ever again. @EvilTester 2
  • 3. Flaky Test Automation is Normal @EvilTester 3
  • 4. Flaky Test Automation is Normal Because we have normalized Flaky Test Automation "Our Tests are Flaky" "Some tests fail Randomly" @EvilTester 4
  • 5. "There is nothing so absurd that it has not been said by some philosopher." Cicero, On Divination, Book II chapter LVIII, section 119 ﴾44 BC﴿ "Truth happens to an idea. It becomes true, is made true by events." William James, Lecture VI, Pragmatism's Conception of Truth, Pragmatism: A New Name for Some Old Ways of Thinking ﴾1907﴿ @EvilTester 5
  • 6. How to Normalize Flaky Test Automation We all know these Test Automation Truths "GUI Automation is Flaky" "We have to live with 'flakiness'" "We shouldn't automate at the GUI" "We can only remove flakiness under the GUI" "Flaky Tests" blames the tests. Not good enough. @EvilTester 6
  • 7. It isn't even the "Tests" We don't automate Tests We automate the execution of steps in a workflow or process We automate the execution of a System We add condition assertions during that execution We don't have flaky Tests ‐ we have automated execution that fails. Sometimes on the steps, sometimes on the assertions. @EvilTester 7
  • 8. 'Flakiness' does not reside at a 'level' I have seen 'flakiness' in Unit Tests in API Tests in Integration Tests in GUI Tests @EvilTester 8
  • 9. It is too easy to say 'flaky' and then blame 'GUI execution' and then blame 'the tool' Living with flakiness is a choice. Choose a different approach. @EvilTester 9
  • 10. I am not the only person saying this. see references at the end and name drops throughout try to cover something different in this talk @EvilTester 10
  • 11. "We designed that flakiness. We are allowing that to happen. We engineered it to be that way. And its our fault that that exists." Richard Bradshaw, "Your Tests aren't Flaky, You Are!" Selenium Conference 2017 https://www.youtube.com/watch?v=XnkWkrbzMh0 @EvilTester 11
  • 12. Take it more seriously. Describe it differently. Intermittent Occurring at irregular intervals; not continuous or steady. https://en.oxforddictionaries.com/definition/intermittent @EvilTester 12
  • 13. Take it more seriously. Describe it differently. Nondeterministic Algorithm "a nondeterministic algorithm is an algorithm that, even for the same input, can exhibit different behaviors on different runs" https://en.wikipedia.org/wiki/Nondeterministic_algorithm @EvilTester 13
  • 14. Flaky is not serious enough. We do not want to use nondeterministic algorithms for continuous assertions that we are relying on @EvilTester 14
  • 15. Your Test Automation is not Flaky Your automated execution fails intermittently @EvilTester 15
  • 16. Don't Blame Tests. Look For Root Causes. watch Alister Scott's GTAC 2015 talk @EvilTester 16
  • 17. I have removed 'flakiness' from Unit Tests from API Tests from Integration Tests from GUI Tests Automated execution does not have to fail intermittently. @EvilTester 17
  • 18. How to remove Intermittent Failure from your Automated Execution 1. Care 2. Investigate 3. Do something about it @EvilTester 18
  • 19. How to remove Intermittent Failure from your Automated Execution 1. Decide Intermittent Failure is unacceptable 2. Investigate the cause of Intermittent Failure 3. Mitigate Remove the cause actually fix it Implement a retry strategy might obscure bugs Accept Intermittent Results might provide hints at solutions @EvilTester 19
  • 20. Take it seriously We write Automate Assertion checking because we care that those assertions are true for each build of the system. Determinism is important. @EvilTester 20
  • 21. High Level Grouping of Common Causes of Intermittency Synchronisation ‐ lack of or poor Parallel Execution ‐ interference Long Running Tests ‐ too long, too risky Automatability ‐ hard to automate system Tools ‐ inappropriate or out of date State Preconditions ‐ not controlled Assertions ‐ wrong or incorrect assumptions Data ‐ not controlled see also Richard Bradshaw and Mark Winteringham "SACRED" Mnemonic. @EvilTester 21
  • 22. Will cover Top 3 for each Grouping @EvilTester 22
  • 23. Top 3 Common Causes ‐ Synchronisation None Time Based Synchronisation Incorrect App State Synchronisation @EvilTester 23
  • 24. Common Solutions ‐ Synchronisation Synchronise on States do not rely on framework Synchronisation Multiple Intermediate States Consider Latency Synchronise in Abstractions not the  @Test methods unless  @Test specific @EvilTester 24
  • 25. Top 3 Common Causes ‐ Parallel Execution Framework not thread safe Tests Interfere Shared Test Environment @EvilTester 25
  • 26. Common Solutions ‐ Parallel Execution Independent environments Independent Data Separate Suites rather than threaded execution Create Threadsafe, reusable code Create reusable library abstractions rather than Frameworks Avoid 'static' singleton objects @EvilTester 26
  • 27. Top 3 Common Causes ‐ Long Running Tests Sequential rather than Model Based not delineating between: preconditions, process, assertion components tests in flow rather than isolation @EvilTester 27
  • 28. Common Solutions ‐ Long Running Tests Understand that more actions == more risk Synchronise prior to each step Consider Model Based Testing Create component test and automated execution playgrounds Minimum assertions @EvilTester 28
  • 29. Top 3 Common Causes ‐ Automatability, Automatizability Not Testability: Application has non‐deterministic behaviour Hard to Synchronise Application fails non‐deterministically in live @EvilTester 29
  • 30. Common Solutions ‐ Automatability, Automatizability Build apps that can be automated Non‐Deterministic apps need step retry strategies rather than test retry strategies @EvilTester 30
  • 31. Top 3 Common Causes ‐ Tools Out of Date Inappropriate Local Tool Infrastructure @EvilTester 31
  • 32. Common Solutions ‐ Tools Use the right tool for the job Keep your tooling environment controlled and up to date Change your approach to take latency into account process on server return results return source, process on execution client @EvilTester 32
  • 33. Top 3 Common Causes ‐ State Preconditions Not Checking State Preconditions at start of test Not controlling state preconditions prior to test Precondition setup using same tool @EvilTester 33
  • 34. Common Solutions ‐ State Preconditions control data precondition state setup ‐ whatever works http, db, api ‐ 'hack it in' avoid dependencies between execution unless a long running test @EvilTester 34
  • 35. Top 3 Common Causes ‐ Assumptions Encoded in Assertions Assert on an Ordered Set Assert on Uncontrolled Data Assertion Tolerences @EvilTester 35
  • 36. Common Solutions ‐ Assumptions Encoded in Assertions Logging so you can interrogate failure afterwards Ability to re‐run tests with same data and setup @EvilTester 36
  • 37. Top 3 Common Causes ‐ Data Missing Data Externally controlled data Uncontrolled Data @EvilTester 37
  • 38. Common Solutions ‐ Data Create data for each test Avoid test dependencies Avoid re‐using data between tests Check data as a precondition Data synchronisation on all precondition data @EvilTester 38
  • 39. Summary Your Test Execution is not 'flaky', it is failing intermittently It is possible to remove intermittent failures, even when automating through a GUI Commons solutions: synchronisation, data control, environmental isolation @EvilTester 39
  • 40. Other talks to watch Alister Scott, GTAC 2015: Your Tests Aren't Flaky https://www.youtube.com/watch?v=hmk1h40shaE Richard Bradshaw, "Your Tests aren't Flaky, You Are!" Selenium Conference 2017 https://www.youtube.com/watch?v=XnkWkrbzMh0 @EvilTester 40
  • 41. Other talks to watch Craig Schwarzwald, SAY GOODBYE TO THE “F” WORD … FLAKY NO MORE! https://www.youtube.com/watch?v=2K2M7s_Ups0 Mark Winteringham ‐ REST APIs and WebDriver: In Perfect Harmony https://www.youtube.com/watch?v=ugAlCZBMOvM Search also for: Flaky Selenium, Flaky Automation, Flaky Test Automation @EvilTester 41
  • 42. End Alan Richardson www.compendiumdev.co.uk Linkedin ‐ @eviltester Twitter ‐ @eviltester Instagram ‐ @eviltester Facebook ‐ @eviltester Youtube ‐ EvilTesterVideos Pinterest ‐ @eviltester Github ‐ @eviltester Slideshare ‐ @eviltester @EvilTester 42
  • 43. BIO Alan is a Software Development and Testing Coach/Consultant who enjoys testing at a technical level using techniques from psychotherapy and computer science. In his spare time Alan is currently programming a Twitter client called ChatterScan, and multi‐user text adventure game. Alan is the author of the books "Dear Evil Tester", "Java For Testers" and "Automating and Testing a REST API". Alan's main website is compendiumdev.co.uk and he blogs at blog.eviltester.com @EvilTester 43