SlideShare a Scribd company logo
A Technical Deep Dive into Practical Test
Automation
Fusion Meetup (Birmingham) March 2017
Alan Richardson
www.eviltester.com
www.compendiumdev.co.uk
@eviltester
@EvilTester 1
Synopsis
In this talk I'm going to focus on the technical aspects of 'test
automation', using examples of approaches from a variety of Agile
projects where we automated APIs, and GUIs. You'll learn about the
use of abstractions and how to think about modeling the system in
code to support automating it. Also how to use these abstractions to
support stress testing, exploratory testing, ongoing CI assertions and
the testing process in general. I'll also discuss the different styles of
coding used to support automating tactically vs automating
strategically.
@EvilTester 2
Secrets of Successful Practical
Automating
Get work done
Automate Flows
Multiple Abstractions
Abstract to libraries, not frameworks
@EvilTester 3
Testing field argues about
Testing vs Checking
You can't automate testing
"Test Automation" is contentious
@EvilTester 4
An Example "This is a test?"
@Test
public void createPreviewMVP() throws IOException {
  String args[] = { 
     new File(System.getProperty("user.dir"),
        "pandocifier.properties").getAbsolutePath()};
        
  new PandocifierCLI().main(args);
  String propertyFileName = args[0];
  File propertyFile = new File(propertyFileName);
  PandocifierConfig config;
  config = new PandocifierConfigFileReader().
               fromPropertyFile(propertyFile);
        
  Assert.assertTrue(new File(
                      config.getPreviewFileName()).exists());
}
@EvilTester 5
An Example "Ce n'est pas un test"
This is a Test because it says it is a  @Test 
This is an Automated Test because it checks something (file
exists)
This is an Automated Test because it Asserts on the check
This is an Application ‑ I use it to build one of my books
This is not an Application ‑ it doesn't have a GUI or a standalone
execution build
This is  automated execution of a process 
@EvilTester 6
We Automate Parts of our Development
Process: Coding, Checking, Asserting, ...
@EvilTester 7
Tactical Reality ‑ I don't really care, I just
want to get work done
Suggests we also have 'strategic reality'
@EvilTester 8
Automating Tactically vs Strategically
What is Tactical? What is Strategic?
Solve a problem Agreed & Understood Goals
Short Term Long Term
Change as necessary Slower to Change
Your Time 'project' time
@EvilTester 9
Warning ‑ sometimes tactics look like
strategy
Use of Jenkins is not Continuous Integration
Automated Deployments are not CI
Containers are not always good environment provision
Page Objects are not guaranteed good system abstractions
@EvilTester 10
You know you are Automating
strategically when...
Reduced Maintenance
Reduced change
Everyone agrees why
No fighting for 'time'
It's not about roles
It gets done
@EvilTester 11
How do we automate?
not about "test automation"
it is about automating tasks
automate the assertions used to check that the stories are still
'done'
Automate
flows through the system
vary data
abstract the execution
@EvilTester 12
Automating Strategically
Abstractions ‑ "modeling the system in code"
abstractions are a big part of automating strategically
abstractions are about modelling ‑ people seem to be scared of
having too many models
see also "Domain Driven Design"
@EvilTester 13
No Abstractions ‑ Web Testing
@Test
public void canCreateAToDoWithNoAbstraction(){
 driver = new FirefoxDriver();
 driver.get(
     "http://todomvc.com/architecture‐examples/backbone/");
 int originalNumberOfTodos = driver.findElements(
             By.cssSelector("ul#todo‐list li")).size();
 WebElement createTodo;
 createTodo = driver.findElement(By.id("new‐todo"));
 createTodo.click();
 createTodo.sendKeys("new task");
 createTodo.sendKeys(Keys.ENTER);
 assertThat(driver.findElement(
       By.id("filters")).isDisplayed(), is(true));
 int newToDos = driver.findElements(
          By.cssSelector("ul#todo‐list li")).size();
  assertThat(newToDos, greaterThan(originalNumberOfTodos));
}
@EvilTester 14
But there were Abstractions
WebDriver ‑ abstration of browser
FirefoxDriver ‑ abstraction Firefox (e.g. no version)
WebElement ‑ abstraction of a dom element
createToDo ‑ variable ‑ named for clarity
Locator Abstractions via methods  findElement  findElements 
Manipulation Abstractions  .sendKeys 
Locator Strategies  By.id (did not have to write CSS Selectors)
...
Lots of Abstractions
@EvilTester 15
Using Abstractions ‑ Same flow
@Test
public void canCreateAToDoWithAbstraction(){
  TodoMVCUser user = 
        new TodoMVCUser(driver, new TodoMVCSite());
  user.opensApplication().and().createNewToDo("new task");
  ApplicationPageFunctional page = 
          new ApplicationPageFunctional(driver, 
          new TodoMVCSite());
  assertThat(page.getCountOfTodoDoItems(), is(1));
  assertThat(page.isFooterVisible(), is(true));
}
@EvilTester 16
What Abstractions were there?
 TodoMVCUser 
User
Intent/Action Based
High Level
 ApplicationPageFunctional 
Structural
Models the rendering of the application page
@EvilTester 17
REST Test ‑ No Abstractions
@Test
public void aUserCanAccessWithBasicAuthHeader(){
  given().
    contentType("text/xml").
    auth().preemptive().basic(
      TestEnvDefaults.getAdminUserName(),
      TestEnvDefaults.getAdminUserPassword()).
  expect().
     statusCode(200).
  when().
     get(TestEnvDefaults.getURL().toExternalForm() +
         TracksApiEndPoints.todos);
}
@EvilTester 18
But there were Abstractions
RESTAssured ‑  given ,  when ,  then ,  expect ,  auth , etc.
RESTAssured is an abstraction layer
Environment abstractions i.e.  TestEnvDefaults 
Lots of Abstractions
But a lack of flexibility
@EvilTester 19
Different abstractions to support
flexibility
@Test
public void aUserCanAuthenticateAndUseAPIWithBasicAuth(){
  HttpMessageSender http = new HttpMessageSender(
                                   TestEnvDefaults.getURL());
  http.basicAuth( TestEnvDefaults.getAdminUserName(),
                  TestEnvDefaults.getAdminUserPassword());
  Response response = http.getResponseFrom(
                                  TracksApiEndPoints.todos);
  Assert.assertEquals(200, response.getStatusCode());
}
@EvilTester 20
Supports
exploratory testing
simple performance testing ‑ multithreaded
Variety
only variety can destroy/absorb variety
(W. Ross Ashby/Stafford Beer)
@EvilTester 21
Models
We have a lot of models
user intent model ‑ what I want to achieve
user action model ‑ how I do that
interface messaging model ‑ how the system implements that
admin models, support models, GUI models
And models overlap
user can use the API or the GUI to do the same things
@EvilTester 22
As programmers we already know how to
handle that
the same things 'interfaces'
different implementations do the same thing 'dependency
injection'
user = new User().using(new API_implementation())
user = new User().using(new GUI_implementation())
 @Test usage unchanged
project = user.createNewProject("my new project")
user.addTaskToProject("my first task", project)
@EvilTester 23
Abstractions are DSL to support the
person writing and maintaining and
reviewing the test
 user.addTaskToProject("my first task", project) 
we can change them to make  @Test code more
readable
 user.forProject(project).addTask("my first task") 
@EvilTester 24
Abstractions can make developers
nervous
too much code
too many layers
@EvilTester 25
When we don't do this
test code takes a long time to maintain
test code takes too long to write
test code is hard to understand
test code is brittle ‑ "every time we change the app the tests
break/ we have to change test code"
execution is flaky ‑ intermittent test runs ‑ "try running the tests
again"
@EvilTester 26
Flaky ‑ often implies poor
synchronization
Understand if your 'framework' is synchronising for you
Frameworks do not sync on application state, they sync on
'framework' state
Synchronise on minimum application state
e.g.
when page loads, wait till it is ready
then all other actions require no synchronisation
if Ajax involved then wait for stable Dom
@EvilTester 27
Writing  @Test DSL code means that
test code is written at the level of the test
it is easy to write
it is easy to understand
the abstraction layers have to be maintained when the
application changes
the  @Test code only changes when the test scenario changes
could re‑use  @Test at the API and at the GUI and in between
@EvilTester 28
Tactical Approach on Agile projects
exploratory testing to get the story to done
create a tech debt backlog for 'missing' automated tests
 @Test code is tactical and we can knock it up (not as good as
production)
@EvilTester 29
Strategic Approach on Agile Projects
automate the checking of acceptance criteria to get the story to
done
ongoing execution of the automated assertions for the life of the
story
implies
maintain this for the life of the story in the application
deleting the @Test code when no longer relevant
amending code structure to make relevant as stories
change and evolve
 @Test code as strategic asset (just like production code)
@EvilTester 30
Abstractions support different types of
testing
exploratory testing
stress/performance testing (bot example) requires thread safe
abstractions
Good abstractions encourage creativity, they do
not force compliance and restrict flexibility.
@EvilTester 31
Why labour the point?
"test automation" often means "testers do the automating"
testers may not program as well as programmers
testers may not know various patterns of writing code
when programmers see  @Test code written by testers they
often don't want to touch it or maintain it
@EvilTester 32
Move from Abstractions such as
'Programming' and 'Testing' to
'Developing'
I say I'm a "test consultant" but the reality is that I'm a "software
development consultant", and part of the process of developing is
testing.
@EvilTester 33
Summary
Automate Strategically on Projects
ongoing assertion checking automated in @Test code
Abstractions model the system in code
Write abstractions at the domain level of the assertion concern
Good abstractions can be used to support exploratory testing
Write good code all the time
@EvilTester 34
Learn to "Be Evil"
www.eviltester.com
@eviltester
www.youtube.com/user/EviltesterVideos
@EvilTester 35
Learn About Alan Richardson
www.compendiumdev.co.uk
uk.linkedin.com/in/eviltester
@EvilTester 36
Follow
Linkedin ‑ @eviltester
Twitter ‑ @eviltester
Instagram ‑ @eviltester
Facebook ‑ @eviltester
Youtube ‑ EvilTesterVideos
Pinterest ‑ @eviltester
Github ‑ @eviltester
Slideshare ‑ @eviltester
@EvilTester 37
BIO
Alan is a test consultant who enjoys testing at a technical level using
techniques from psychotherapy and computer science. In his spare
time Alan is currently programming a multi‑user text adventure game
and some buggy JavaScript games in the style of the Cascade
Cassette 50. 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 38

More Related Content

What's hot (20)

PDF
Evil testers guide to technical testing
Alan Richardson
 
PDF
Black Ops Testing Workshop from Agile Testing Days 2014
Alan Richardson
 
PDF
Effective Software Testing for Modern Software Development
Alan Richardson
 
PDF
Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...
Alan Richardson
 
PDF
Secrets and Mysteries of Automated Execution Keynote slides
Alan Richardson
 
PDF
Add More Security To Your Testing and Automating - Saucecon 2021
Alan Richardson
 
PDF
Technology Based Testing
Alan Richardson
 
PDF
Confessions of an Accidental Security Tester
Alan Richardson
 
PDF
Technical Testing Webinar
Alan Richardson
 
PDF
TestIstanbul May 2013 Keynote Experiences With Exploratory Testing
Alan Richardson
 
PPTX
Risk Mitigation Using Exploratory and Technical Testing - QASymphony Webinar ...
Alan Richardson
 
PDF
Selenium Clinic Eurostar 2012 WebDriver Tutorial
Alan Richardson
 
PDF
Lessons Learned When Automating
Alan Richardson
 
PDF
Odinstar 2017 - Real World Automating to Support Testing
Alan Richardson
 
PDF
Push Functional Testing Further
Alan Richardson
 
PDF
Your Automated Execution Does Not Have to be Flaky
Alan Richardson
 
PDF
Technical and Testing Challenges: Using the "Protect The Square" Game
Alan Richardson
 
PDF
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
Alan Richardson
 
PPTX
Battle of The Mocking Frameworks
Dror Helper
 
PPTX
Building unit tests correctly with visual studio 2013
Dror Helper
 
Evil testers guide to technical testing
Alan Richardson
 
Black Ops Testing Workshop from Agile Testing Days 2014
Alan Richardson
 
Effective Software Testing for Modern Software Development
Alan Richardson
 
Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...
Alan Richardson
 
Secrets and Mysteries of Automated Execution Keynote slides
Alan Richardson
 
Add More Security To Your Testing and Automating - Saucecon 2021
Alan Richardson
 
Technology Based Testing
Alan Richardson
 
Confessions of an Accidental Security Tester
Alan Richardson
 
Technical Testing Webinar
Alan Richardson
 
TestIstanbul May 2013 Keynote Experiences With Exploratory Testing
Alan Richardson
 
Risk Mitigation Using Exploratory and Technical Testing - QASymphony Webinar ...
Alan Richardson
 
Selenium Clinic Eurostar 2012 WebDriver Tutorial
Alan Richardson
 
Lessons Learned When Automating
Alan Richardson
 
Odinstar 2017 - Real World Automating to Support Testing
Alan Richardson
 
Push Functional Testing Further
Alan Richardson
 
Your Automated Execution Does Not Have to be Flaky
Alan Richardson
 
Technical and Testing Challenges: Using the "Protect The Square" Game
Alan Richardson
 
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
Alan Richardson
 
Battle of The Mocking Frameworks
Dror Helper
 
Building unit tests correctly with visual studio 2013
Dror Helper
 

Viewers also liked (20)

PPTX
Selenium introduction
HGanesh
 
PPT
Automation test
Zhida Lan
 
PPTX
Continuous Delivery Conference 2014 - Bas Dijkstra
Bas Dijkstra
 
PDF
Automation Using Selenium Webdriver
Edureka!
 
PDF
Automation Abstraction Layers: Page Objects and Beyond
Alan Richardson
 
PDF
Introduction to selenium_grid_workshop
seleniumconf
 
PDF
Tj bot 0317實作坊 組裝篇
湯米吳 Tommy Wu
 
PPTX
20000 Leagues Under the Sea: Diving Into the Slack Infrastructure
Raissa Largman
 
PPTX
Get Started With Selenium 3 and Selenium 3 Grid
Daniel Herken
 
PPT
Introduction to Selenium
rohitnayak
 
PDF
Page Objects Done Right - selenium conference 2014
Oren Rubin
 
PDF
Joint slides Isabel Evans Alan Richardson Feb UKStar 2017
Alan Richardson
 
PPT
Selenium
Ruturaj Doshi
 
PDF
Perils of Page-Object Pattern
Anand Bagmar
 
PDF
Selenium grid workshop london 2016
Marcus Merrell
 
PPTX
Continuous Delivery With Selenium Grid And Docker
Barbara Gonzalez
 
PPT
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Atirek Gupta
 
PPTX
Selenium web driver
Sun Technlogies
 
PPT
Test Automation Best Practices (with SOA test approach)
Leonard Fingerman
 
PDF
Patterns of a “good” test automation framework
Anand Bagmar
 
Selenium introduction
HGanesh
 
Automation test
Zhida Lan
 
Continuous Delivery Conference 2014 - Bas Dijkstra
Bas Dijkstra
 
Automation Using Selenium Webdriver
Edureka!
 
Automation Abstraction Layers: Page Objects and Beyond
Alan Richardson
 
Introduction to selenium_grid_workshop
seleniumconf
 
Tj bot 0317實作坊 組裝篇
湯米吳 Tommy Wu
 
20000 Leagues Under the Sea: Diving Into the Slack Infrastructure
Raissa Largman
 
Get Started With Selenium 3 and Selenium 3 Grid
Daniel Herken
 
Introduction to Selenium
rohitnayak
 
Page Objects Done Right - selenium conference 2014
Oren Rubin
 
Joint slides Isabel Evans Alan Richardson Feb UKStar 2017
Alan Richardson
 
Selenium
Ruturaj Doshi
 
Perils of Page-Object Pattern
Anand Bagmar
 
Selenium grid workshop london 2016
Marcus Merrell
 
Continuous Delivery With Selenium Grid And Docker
Barbara Gonzalez
 
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Atirek Gupta
 
Selenium web driver
Sun Technlogies
 
Test Automation Best Practices (with SOA test approach)
Leonard Fingerman
 
Patterns of a “good” test automation framework
Anand Bagmar
 
Ad

Similar to Practical Test Automation Deep Dive (20)

PDF
Test Automation
nikos batsios
 
PDF
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
Perfecto by Perforce
 
PDF
SauceCon 2017: Making Your Mobile App Automatable
Sauce Labs
 
PDF
10 Lessons learned in test automation
Romania Testing
 
PDF
TLC2018 Thomas Haver: The Automation Firehose - Be Strategic and Tactical
Anna Royzman
 
PDF
Lee Barnes - What Successful Test Automation is.pdf
QA or the Highway
 
PDF
InnovateQA Seattle2024_Lee Barnes_What Effective Test Automation is.pdf
anna360704
 
PPTX
Solving the Automation Puzzle - how to select the right automation framework ...
Ori Bendet
 
PDF
Future of Test Automation with Latest Trends in Software Testing.pdf
kalichargn70th171
 
PPTX
When & How to Successfully use Test Automation for Mobile Applications
TechnologyAssociationOregon
 
PDF
Future of Test Automation with Latest Trends in Software Testing.pdf
flufftailshop
 
PDF
How to build confidence in your release cycle
DiUS
 
PPTX
Diving into the World of Test Automation The Approach and the Technologies
QASymphony
 
PPTX
Curiosity and Infuse Consulting Present: Sustainable Test Automation Strategi...
Curiosity Software Ireland
 
PDF
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
leebarnesutopia
 
PDF
Automation Abstractions: Page Objects and Beyond
TechWell
 
PDF
Functional and Non-functional Test automation
Dr Ganesh Iyer
 
PDF
Swiss Testing Day - Testautomation, 10 (sometimes painful) lessons learned
Michael Palotas
 
PPTX
Real Testing Scenario Strategy - Bringing It All Together For Success
Adam Sandman
 
PPT
Designing a Test Automation Framework By Quontra solutions
QUONTRASOLUTIONS
 
Test Automation
nikos batsios
 
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
Perfecto by Perforce
 
SauceCon 2017: Making Your Mobile App Automatable
Sauce Labs
 
10 Lessons learned in test automation
Romania Testing
 
TLC2018 Thomas Haver: The Automation Firehose - Be Strategic and Tactical
Anna Royzman
 
Lee Barnes - What Successful Test Automation is.pdf
QA or the Highway
 
InnovateQA Seattle2024_Lee Barnes_What Effective Test Automation is.pdf
anna360704
 
Solving the Automation Puzzle - how to select the right automation framework ...
Ori Bendet
 
Future of Test Automation with Latest Trends in Software Testing.pdf
kalichargn70th171
 
When & How to Successfully use Test Automation for Mobile Applications
TechnologyAssociationOregon
 
Future of Test Automation with Latest Trends in Software Testing.pdf
flufftailshop
 
How to build confidence in your release cycle
DiUS
 
Diving into the World of Test Automation The Approach and the Technologies
QASymphony
 
Curiosity and Infuse Consulting Present: Sustainable Test Automation Strategi...
Curiosity Software Ireland
 
Lee Barnes - Path to Becoming an Effective Test Automation Engineer.pdf
leebarnesutopia
 
Automation Abstractions: Page Objects and Beyond
TechWell
 
Functional and Non-functional Test automation
Dr Ganesh Iyer
 
Swiss Testing Day - Testautomation, 10 (sometimes painful) lessons learned
Michael Palotas
 
Real Testing Scenario Strategy - Bringing It All Together For Success
Adam Sandman
 
Designing a Test Automation Framework By Quontra solutions
QUONTRASOLUTIONS
 
Ad

More from Alan Richardson (18)

PDF
Open source tools - Test Management Summit - 2009
Alan Richardson
 
PDF
The Future of Testing Webinar
Alan Richardson
 
PDF
Joy of Coding Conference 2019 slides - Alan Richardson
Alan Richardson
 
PDF
Programming katas for Software Testers - CounterStrings
Alan Richardson
 
PDF
About Consultant Alan Richardson Compendium Developments Evil Tester
Alan Richardson
 
PDF
Shift left-testing
Alan Richardson
 
PDF
Automating and Testing a REST API
Alan Richardson
 
PDF
TDD - Test Driven Development - Java JUnit FizzBuzz
Alan Richardson
 
PDF
How To Test With Agility
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
What is Regression Testing?
Alan Richardson
 
PDF
Simple ways to add and work with a `.jar` file in your local maven setup
Alan Richardson
 
PDF
Re-thinking Test Automation and Test Process Modelling (in pictures)
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
 
Open source tools - Test Management Summit - 2009
Alan Richardson
 
The Future of Testing Webinar
Alan Richardson
 
Joy of Coding Conference 2019 slides - Alan Richardson
Alan Richardson
 
Programming katas for Software Testers - CounterStrings
Alan Richardson
 
About Consultant Alan Richardson Compendium Developments Evil Tester
Alan Richardson
 
Shift left-testing
Alan Richardson
 
Automating and Testing a REST API
Alan Richardson
 
TDD - Test Driven Development - Java JUnit FizzBuzz
Alan Richardson
 
How To Test With Agility
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
 
What is Regression Testing?
Alan Richardson
 
Simple ways to add and work with a `.jar` file in your local maven setup
Alan Richardson
 
Re-thinking Test Automation and Test Process Modelling (in pictures)
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
 

Recently uploaded (20)

PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
NEW-Viral>Wondershare Filmora 14.5.18.12900 Crack Free
sherryg1122g
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Tally software_Introduction_Presentation
AditiBansal54083
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 

Practical Test Automation Deep Dive

  • 1. A Technical Deep Dive into Practical Test Automation Fusion Meetup (Birmingham) March 2017 Alan Richardson www.eviltester.com www.compendiumdev.co.uk @eviltester @EvilTester 1
  • 2. Synopsis In this talk I'm going to focus on the technical aspects of 'test automation', using examples of approaches from a variety of Agile projects where we automated APIs, and GUIs. You'll learn about the use of abstractions and how to think about modeling the system in code to support automating it. Also how to use these abstractions to support stress testing, exploratory testing, ongoing CI assertions and the testing process in general. I'll also discuss the different styles of coding used to support automating tactically vs automating strategically. @EvilTester 2
  • 3. Secrets of Successful Practical Automating Get work done Automate Flows Multiple Abstractions Abstract to libraries, not frameworks @EvilTester 3
  • 4. Testing field argues about Testing vs Checking You can't automate testing "Test Automation" is contentious @EvilTester 4
  • 5. An Example "This is a test?" @Test public void createPreviewMVP() throws IOException {   String args[] = {       new File(System.getProperty("user.dir"),         "pandocifier.properties").getAbsolutePath()};            new PandocifierCLI().main(args);   String propertyFileName = args[0];   File propertyFile = new File(propertyFileName);   PandocifierConfig config;   config = new PandocifierConfigFileReader().                fromPropertyFile(propertyFile);            Assert.assertTrue(new File(                       config.getPreviewFileName()).exists()); } @EvilTester 5
  • 6. An Example "Ce n'est pas un test" This is a Test because it says it is a  @Test  This is an Automated Test because it checks something (file exists) This is an Automated Test because it Asserts on the check This is an Application ‑ I use it to build one of my books This is not an Application ‑ it doesn't have a GUI or a standalone execution build This is  automated execution of a process  @EvilTester 6
  • 7. We Automate Parts of our Development Process: Coding, Checking, Asserting, ... @EvilTester 7
  • 8. Tactical Reality ‑ I don't really care, I just want to get work done Suggests we also have 'strategic reality' @EvilTester 8
  • 9. Automating Tactically vs Strategically What is Tactical? What is Strategic? Solve a problem Agreed & Understood Goals Short Term Long Term Change as necessary Slower to Change Your Time 'project' time @EvilTester 9
  • 10. Warning ‑ sometimes tactics look like strategy Use of Jenkins is not Continuous Integration Automated Deployments are not CI Containers are not always good environment provision Page Objects are not guaranteed good system abstractions @EvilTester 10
  • 11. You know you are Automating strategically when... Reduced Maintenance Reduced change Everyone agrees why No fighting for 'time' It's not about roles It gets done @EvilTester 11
  • 12. How do we automate? not about "test automation" it is about automating tasks automate the assertions used to check that the stories are still 'done' Automate flows through the system vary data abstract the execution @EvilTester 12
  • 13. Automating Strategically Abstractions ‑ "modeling the system in code" abstractions are a big part of automating strategically abstractions are about modelling ‑ people seem to be scared of having too many models see also "Domain Driven Design" @EvilTester 13
  • 14. No Abstractions ‑ Web Testing @Test public void canCreateAToDoWithNoAbstraction(){  driver = new FirefoxDriver();  driver.get(      "http://todomvc.com/architecture‐examples/backbone/");  int originalNumberOfTodos = driver.findElements(              By.cssSelector("ul#todo‐list li")).size();  WebElement createTodo;  createTodo = driver.findElement(By.id("new‐todo"));  createTodo.click();  createTodo.sendKeys("new task");  createTodo.sendKeys(Keys.ENTER);  assertThat(driver.findElement(        By.id("filters")).isDisplayed(), is(true));  int newToDos = driver.findElements(           By.cssSelector("ul#todo‐list li")).size();   assertThat(newToDos, greaterThan(originalNumberOfTodos)); } @EvilTester 14
  • 15. But there were Abstractions WebDriver ‑ abstration of browser FirefoxDriver ‑ abstraction Firefox (e.g. no version) WebElement ‑ abstraction of a dom element createToDo ‑ variable ‑ named for clarity Locator Abstractions via methods  findElement  findElements  Manipulation Abstractions  .sendKeys  Locator Strategies  By.id (did not have to write CSS Selectors) ... Lots of Abstractions @EvilTester 15
  • 16. Using Abstractions ‑ Same flow @Test public void canCreateAToDoWithAbstraction(){   TodoMVCUser user =          new TodoMVCUser(driver, new TodoMVCSite());   user.opensApplication().and().createNewToDo("new task");   ApplicationPageFunctional page =            new ApplicationPageFunctional(driver,            new TodoMVCSite());   assertThat(page.getCountOfTodoDoItems(), is(1));   assertThat(page.isFooterVisible(), is(true)); } @EvilTester 16
  • 17. What Abstractions were there?  TodoMVCUser  User Intent/Action Based High Level  ApplicationPageFunctional  Structural Models the rendering of the application page @EvilTester 17
  • 18. REST Test ‑ No Abstractions @Test public void aUserCanAccessWithBasicAuthHeader(){   given().     contentType("text/xml").     auth().preemptive().basic(       TestEnvDefaults.getAdminUserName(),       TestEnvDefaults.getAdminUserPassword()).   expect().      statusCode(200).   when().      get(TestEnvDefaults.getURL().toExternalForm() +          TracksApiEndPoints.todos); } @EvilTester 18
  • 19. But there were Abstractions RESTAssured ‑  given ,  when ,  then ,  expect ,  auth , etc. RESTAssured is an abstraction layer Environment abstractions i.e.  TestEnvDefaults  Lots of Abstractions But a lack of flexibility @EvilTester 19
  • 20. Different abstractions to support flexibility @Test public void aUserCanAuthenticateAndUseAPIWithBasicAuth(){   HttpMessageSender http = new HttpMessageSender(                                    TestEnvDefaults.getURL());   http.basicAuth( TestEnvDefaults.getAdminUserName(),                   TestEnvDefaults.getAdminUserPassword());   Response response = http.getResponseFrom(                                   TracksApiEndPoints.todos);   Assert.assertEquals(200, response.getStatusCode()); } @EvilTester 20
  • 21. Supports exploratory testing simple performance testing ‑ multithreaded Variety only variety can destroy/absorb variety (W. Ross Ashby/Stafford Beer) @EvilTester 21
  • 22. Models We have a lot of models user intent model ‑ what I want to achieve user action model ‑ how I do that interface messaging model ‑ how the system implements that admin models, support models, GUI models And models overlap user can use the API or the GUI to do the same things @EvilTester 22
  • 23. As programmers we already know how to handle that the same things 'interfaces' different implementations do the same thing 'dependency injection' user = new User().using(new API_implementation()) user = new User().using(new GUI_implementation())  @Test usage unchanged project = user.createNewProject("my new project") user.addTaskToProject("my first task", project) @EvilTester 23
  • 24. Abstractions are DSL to support the person writing and maintaining and reviewing the test  user.addTaskToProject("my first task", project)  we can change them to make  @Test code more readable  user.forProject(project).addTask("my first task")  @EvilTester 24
  • 25. Abstractions can make developers nervous too much code too many layers @EvilTester 25
  • 26. When we don't do this test code takes a long time to maintain test code takes too long to write test code is hard to understand test code is brittle ‑ "every time we change the app the tests break/ we have to change test code" execution is flaky ‑ intermittent test runs ‑ "try running the tests again" @EvilTester 26
  • 27. Flaky ‑ often implies poor synchronization Understand if your 'framework' is synchronising for you Frameworks do not sync on application state, they sync on 'framework' state Synchronise on minimum application state e.g. when page loads, wait till it is ready then all other actions require no synchronisation if Ajax involved then wait for stable Dom @EvilTester 27
  • 28. Writing  @Test DSL code means that test code is written at the level of the test it is easy to write it is easy to understand the abstraction layers have to be maintained when the application changes the  @Test code only changes when the test scenario changes could re‑use  @Test at the API and at the GUI and in between @EvilTester 28
  • 29. Tactical Approach on Agile projects exploratory testing to get the story to done create a tech debt backlog for 'missing' automated tests  @Test code is tactical and we can knock it up (not as good as production) @EvilTester 29
  • 30. Strategic Approach on Agile Projects automate the checking of acceptance criteria to get the story to done ongoing execution of the automated assertions for the life of the story implies maintain this for the life of the story in the application deleting the @Test code when no longer relevant amending code structure to make relevant as stories change and evolve  @Test code as strategic asset (just like production code) @EvilTester 30
  • 31. Abstractions support different types of testing exploratory testing stress/performance testing (bot example) requires thread safe abstractions Good abstractions encourage creativity, they do not force compliance and restrict flexibility. @EvilTester 31
  • 32. Why labour the point? "test automation" often means "testers do the automating" testers may not program as well as programmers testers may not know various patterns of writing code when programmers see  @Test code written by testers they often don't want to touch it or maintain it @EvilTester 32
  • 33. Move from Abstractions such as 'Programming' and 'Testing' to 'Developing' I say I'm a "test consultant" but the reality is that I'm a "software development consultant", and part of the process of developing is testing. @EvilTester 33
  • 34. Summary Automate Strategically on Projects ongoing assertion checking automated in @Test code Abstractions model the system in code Write abstractions at the domain level of the assertion concern Good abstractions can be used to support exploratory testing Write good code all the time @EvilTester 34
  • 35. Learn to "Be Evil" www.eviltester.com @eviltester www.youtube.com/user/EviltesterVideos @EvilTester 35
  • 36. Learn About Alan Richardson www.compendiumdev.co.uk uk.linkedin.com/in/eviltester @EvilTester 36
  • 37. Follow Linkedin ‑ @eviltester Twitter ‑ @eviltester Instagram ‑ @eviltester Facebook ‑ @eviltester Youtube ‑ EvilTesterVideos Pinterest ‑ @eviltester Github ‑ @eviltester Slideshare ‑ @eviltester @EvilTester 37
  • 38. BIO Alan is a test consultant who enjoys testing at a technical level using techniques from psychotherapy and computer science. In his spare time Alan is currently programming a multi‑user text adventure game and some buggy JavaScript games in the style of the Cascade Cassette 50. 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 38