SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...
Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...
Test Bash Netherlands Alan Richardson "How to misuse 'Automation' for testing...
Alan Richardson
 
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
Alan Richardson
 

Was ist angesagt? (20)

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

Andere mochten auch

Introduction to selenium_grid_workshop
Introduction to selenium_grid_workshopIntroduction to selenium_grid_workshop
Introduction to selenium_grid_workshop
seleniumconf
 

Andere mochten auch (20)

Selenium introduction
Selenium introductionSelenium introduction
Selenium introduction
 
Automation test
Automation testAutomation test
Automation test
 
Continuous Delivery Conference 2014 - Bas Dijkstra
Continuous Delivery Conference 2014 - Bas DijkstraContinuous Delivery Conference 2014 - Bas Dijkstra
Continuous Delivery Conference 2014 - Bas Dijkstra
 
Automation Using Selenium Webdriver
Automation Using Selenium WebdriverAutomation Using Selenium Webdriver
Automation Using Selenium Webdriver
 
Automation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAutomation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and Beyond
 
Introduction to selenium_grid_workshop
Introduction to selenium_grid_workshopIntroduction to selenium_grid_workshop
Introduction to selenium_grid_workshop
 
Tj bot 0317實作坊 組裝篇
Tj bot 0317實作坊 組裝篇Tj bot 0317實作坊 組裝篇
Tj bot 0317實作坊 組裝篇
 
20000 Leagues Under the Sea: Diving Into the Slack Infrastructure
20000 Leagues Under the Sea: Diving Into the Slack Infrastructure20000 Leagues Under the Sea: Diving Into the Slack Infrastructure
20000 Leagues Under the Sea: Diving Into the Slack Infrastructure
 
Get Started With Selenium 3 and Selenium 3 Grid
Get Started With Selenium 3 and Selenium 3 GridGet Started With Selenium 3 and Selenium 3 Grid
Get Started With Selenium 3 and Selenium 3 Grid
 
Introduction to Selenium
Introduction to SeleniumIntroduction to Selenium
Introduction to Selenium
 
Page Objects Done Right - selenium conference 2014
Page Objects Done Right - selenium conference 2014Page Objects Done Right - selenium conference 2014
Page Objects Done Right - selenium conference 2014
 
Joint slides Isabel Evans Alan Richardson Feb UKStar 2017
Joint slides Isabel Evans Alan Richardson Feb UKStar 2017Joint slides Isabel Evans Alan Richardson Feb UKStar 2017
Joint slides Isabel Evans Alan Richardson Feb UKStar 2017
 
Selenium
SeleniumSelenium
Selenium
 
Perils of Page-Object Pattern
Perils of Page-Object PatternPerils of Page-Object Pattern
Perils of Page-Object Pattern
 
Selenium grid workshop london 2016
Selenium grid workshop london 2016Selenium grid workshop london 2016
Selenium grid workshop london 2016
 
Continuous Delivery With Selenium Grid And Docker
Continuous Delivery With Selenium Grid And DockerContinuous Delivery With Selenium Grid And Docker
Continuous Delivery With Selenium Grid And Docker
 
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
 
Selenium web driver
Selenium web driverSelenium web driver
Selenium web driver
 
Test Automation Best Practices (with SOA test approach)
Test Automation Best Practices (with SOA test approach)Test Automation Best Practices (with SOA test approach)
Test Automation Best Practices (with SOA test approach)
 
Patterns of a “good” test automation framework
Patterns of a “good” test automation frameworkPatterns of a “good” test automation framework
Patterns of a “good” test automation framework
 

Ähnlich wie Practical Test Automation Deep Dive

The Testing Planet Issue 2
The Testing Planet Issue 2The Testing Planet Issue 2
The Testing Planet Issue 2
Rosie Sherry
 
Software Requirements Engineering Methodologies
Software Requirements Engineering MethodologiesSoftware Requirements Engineering Methodologies
Software Requirements Engineering Methodologies
Kiran Munir
 
Keyword Driven Testing
Keyword Driven TestingKeyword Driven Testing
Keyword Driven Testing
Harish MS
 

Ähnlich wie Practical Test Automation Deep Dive (20)

Testing Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation FrameworksTesting Experience - Evolution of Test Automation Frameworks
Testing Experience - Evolution of Test Automation Frameworks
 
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databases#DOAW16 - DevOps@work Roma 2016 - Testing your databases
#DOAW16 - DevOps@work Roma 2016 - Testing your databases
 
The Testing Planet Issue 2
The Testing Planet Issue 2The Testing Planet Issue 2
The Testing Planet Issue 2
 
Why test with flex unit
Why test with flex unitWhy test with flex unit
Why test with flex unit
 
Software Requirements Engineering Methodologies
Software Requirements Engineering MethodologiesSoftware Requirements Engineering Methodologies
Software Requirements Engineering Methodologies
 
Slides for Automation Testing or End to End testing
Slides for Automation Testing or End to End testingSlides for Automation Testing or End to End testing
Slides for Automation Testing or End to End testing
 
Test design techniques
Test design techniquesTest design techniques
Test design techniques
 
TDD Workshop UTN 2012
TDD Workshop UTN 2012TDD Workshop UTN 2012
TDD Workshop UTN 2012
 
Keyword Driven Testing
Keyword Driven TestingKeyword Driven Testing
Keyword Driven Testing
 
Automated testing-whitepaper
Automated testing-whitepaperAutomated testing-whitepaper
Automated testing-whitepaper
 
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web TestingThe Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
The Automation Firehose: Be Strategic & Tactical With Your Mobile & Web Testing
 
TLC2018 Thomas Haver: The Automation Firehose - Be Strategic and Tactical
TLC2018 Thomas Haver: The Automation Firehose - Be Strategic and TacticalTLC2018 Thomas Haver: The Automation Firehose - Be Strategic and Tactical
TLC2018 Thomas Haver: The Automation Firehose - Be Strategic and Tactical
 
The Automation Firehose: Be Strategic and Tactical by Thomas Haver
The Automation Firehose: Be Strategic and Tactical by Thomas HaverThe Automation Firehose: Be Strategic and Tactical by Thomas Haver
The Automation Firehose: Be Strategic and Tactical by Thomas Haver
 
Automation Best Practices.pptx
Automation Best Practices.pptxAutomation Best Practices.pptx
Automation Best Practices.pptx
 
Susan windsor soft test 16th november 2005
Susan windsor soft test   16th november 2005Susan windsor soft test   16th november 2005
Susan windsor soft test 16th november 2005
 
Successful Software Projects - What you need to consider
Successful Software Projects - What you need to considerSuccessful Software Projects - What you need to consider
Successful Software Projects - What you need to consider
 
12 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 200912 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 2009
 
Building Maintainable Android Apps (DroidCon NYC 2014)
Building Maintainable Android Apps (DroidCon NYC 2014)Building Maintainable Android Apps (DroidCon NYC 2014)
Building Maintainable Android Apps (DroidCon NYC 2014)
 
Mocking with Mockito
Mocking with MockitoMocking with Mockito
Mocking with Mockito
 
'BIG Testing' with Hans Buwalda
'BIG Testing' with Hans Buwalda 'BIG Testing' with Hans Buwalda
'BIG Testing' with Hans Buwalda
 

Mehr von Alan Richardson

Mehr von Alan Richardson (18)

Open source tools - Test Management Summit - 2009
Open source tools - Test Management Summit - 2009Open source tools - Test Management Summit - 2009
Open source tools - Test Management Summit - 2009
 
The Future of Testing Webinar
The Future of Testing WebinarThe Future of Testing Webinar
The Future of Testing Webinar
 
Joy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan RichardsonJoy of Coding Conference 2019 slides - Alan Richardson
Joy of Coding Conference 2019 slides - Alan Richardson
 
Programming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStringsProgramming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStrings
 
About Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil TesterAbout Consultant Alan Richardson Compendium Developments Evil Tester
About Consultant Alan Richardson Compendium Developments Evil Tester
 
Shift left-testing
Shift left-testingShift left-testing
Shift left-testing
 
Automating and Testing a REST API
Automating and Testing a REST APIAutomating and Testing a REST API
Automating and Testing a REST API
 
TDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzzTDD - Test Driven Development - Java JUnit FizzBuzz
TDD - Test Driven Development - Java JUnit FizzBuzz
 
How To Test With Agility
How To Test With AgilityHow To Test With Agility
How To Test With Agility
 
What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.What is Testability vs Automatability? How to improve your Software Testing.
What is Testability vs Automatability? How to improve your Software Testing.
 
What is Agile Testing? A MindMap
What is Agile Testing? A MindMapWhat is Agile Testing? A MindMap
What is Agile Testing? A MindMap
 
Evil Tester's Guide to Agile Testing
Evil Tester's Guide to Agile TestingEvil Tester's Guide to Agile Testing
Evil Tester's Guide to Agile Testing
 
The Evil Tester Show - Episode 001 Halloween 2017
The Evil Tester Show - Episode 001 Halloween 2017The Evil Tester Show - Episode 001 Halloween 2017
The Evil Tester Show - Episode 001 Halloween 2017
 
What is Regression Testing?
What is Regression Testing?What is Regression Testing?
What is Regression Testing?
 
Simple ways to add and work with a `.jar` file in your local maven setup
Simple ways to add and work with a `.jar` file in your local maven setupSimple ways to add and work with a `.jar` file in your local maven setup
Simple ways to add and work with a `.jar` file in your local maven setup
 
Re-thinking Test Automation and Test Process Modelling (in pictures)
Re-thinking Test Automation and Test Process Modelling (in pictures)Re-thinking Test Automation and Test Process Modelling (in pictures)
Re-thinking Test Automation and Test Process Modelling (in pictures)
 
Learning in Public - A How to Speak in Public Workshop
Learning in Public - A How to Speak in Public WorkshopLearning in Public - A How to Speak in Public Workshop
Learning in Public - A How to Speak in Public Workshop
 
How to Practise to Remove Fear of Public Speaking
How to Practise to Remove Fear of Public SpeakingHow to Practise to Remove Fear of Public Speaking
How to Practise to Remove Fear of Public Speaking
 

Kürzlich hochgeladen

Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Kürzlich hochgeladen (20)

Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 

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