SlideShare uma empresa Scribd logo
1 de 21
Testability for developers

Fighting a mess by making it testable


       XP Days Ukraine 2012
       Alexander Tarnowski
Additional note:
This presentation has been slightly adjusted after
the conference. Some images have been removed
and some notes have been added to provide
context.
Ongoing project



     alexander.tarnowski@crisp.se
     alexander_tar
Blog blog.crisp.se/author/alexandertarnowski

www www.techbookreader.com


                                               http://leanpub.com/developer_testing
My system’s dependencies are like spaghetti
My system is ruled by a database
It’s a ritual to deploy my system
My system doesn’t have a business layer
My system has few and poor unit tests
My system’s end-to-end tests don’t work
Frontend                     Legend
                                                       EWC = Enterprise-wide componment
                              Front
                                                            = Depends on
                               end                          = Packaged into


                                                WS developer pack from 2004


”Enterprise-wide” component           Backend

           EWC                         Back
            core                       end
                                        core




           EWC                         Back
           shared                      end
                                       shared




                                       Enterprise message bus library
                                                                       Joker: flickr: GoShows
A number of
                            data sources


Alternative message queue
implementation                              Application’s
                                            config files



?


      Parts of the
      application

                                           Message bus
                                           library


                                                  flickr: Andrew Coulter Enright
One Database to rule them all, One Database to find them,
One Database to bring them all and in the darkness bind them
Additional note:
A lengthy manual deployment
script that’s not up-to-date has a
striking resemblance to
hieroglyphs.


                       flickr: rfzappala
Good idea   Bad idea
            Database




Additional note:
Some frameworks try really hard
to provide persistence as close to
the view as possible. When is that
a good idea?
Είχαν τεςςαρϊν μεταγλωτίςει ασ ςαν, αλφα εκτελείται δεν τι. Από κα χρόνου χαμθλόσ ποςοςτό. Γειτονιάσ εργαηόμενων να πεσ
επενδυτισ το. Χάοσ προςεκτικά δε ςτθ. Όρο πάρα ιδιαίτερα αν, όςο το πετοφν γνωρίηει.
Το όςο γραφικά δθμιουργίεσ χαρακτθριςτικό, όλα μθ ζργων περίπου. Διακοπι οζλεγχοσ χαρακτθριςτικϊν να όχι, μθ Ήδθ ζτςι
Thread.sleep(3000);

χρόνου κα. Στο με όταν λοιπόν ςθμαντικόσ, ζρκει ςχεδιαςτισ ιδθ τι. Ασ τθν γειτονιάσ αγοράηοντασ. Ασ πετοφν αποτελζςει κα μπουν
προςλάμβανεσ, πιο ωσ ςτθν προςπακοφν.
Thread.sleep(3000);
Πω δουλζψει προςεκτικά χαρακτθριςτικϊν ςου, ζςτελνε φακζλουσ ανακλφψεισ τι νζα. Ατόμου αποφάςιςε που τι, προςλάμβανεσ
των, ποςοςτό επιτίκενται το ναι. Πω ερωτιςεισ χρειάηονται λεσ, βιμα πάρεισ κρατάει να κλπ. Τθν ξεχειλίηει. Τθν πετάνε χαμθλόσ
χαρακτθριςτικϊν να, δε κρατιςουν προβλθματικι μθν. Τθ κφκλο κανείσ απίςτευτα ϊρα, αλγόρικμου προβλιματα αντιλιφκθκαν.
Υόρκθ καρζκλα λιγότερο να ότι, τότε μπουν κρατάει πιο οι. Τι ςου γραφικά αρπάηεισ δουλεφουν. Ώσ βακμό δθμιουργίεσ, μια μα κζματα

διοικθτικό, δε πελάτεσ δυςτυχϊσ ςυγχρόνωσ ςασ. Κι τουσ δίνοντασ λεσ. Νζεσ εξαρτάται οι όχι, ϊσ ξζχαςε προϊόντα ότι.
Thread.sleep(1000);
Με μάλλον κακόκεφουσ χρθςιμοποιοφνταν που, μετριςεισ εργοςταςίου παρατθροφμενθ τθ λεσ. Λοιπόν ναί να. Αν ιδθ νζων εκτόσ,
Thread.sleep(2000);

ςασ άρκρων χριματα χρθςιμοποιιςει μθ. Εδϊ άμεςθ ατόμου αναγκάηονται μα, μζςθσ τελικϊν ςφαλμάτων εταιρείεσ τα.
Thread.sleep(3000);
Δοφλευε μθχανισ ροι κι, ϊσ τζτοιο διακοπι αναηιτθςθσ τον, τισ ορίςτε ατόμου εργαηόμενων ϊσ. Όχι λοιπόν κρατάει κα. Μάκε όχι




Additional note:
Long record/playback tests with
incorrect handling of
asynchronicity tend to look like
Greek after a while.


                                                                                                                                   flickr: bunky’s pickle
Dependency spaghetti

        Few and poor                              Unknown app server
          unit tests                                 configuration




       Data
       base             Where do we start
No business layer                                        Record/playback
                                                          (with timing issues)




                    Manual deployment     One database
What                      Why

New code unit-tested      We’re in a hole and we
                          don’t want to dig deeper
Create a business layer   Quality in the long run
Automated end-to-end      • Initiate change
tests for happy paths     • ”Quick” wins
@Test
public void aUserCanLogIn() {
      application.login(”testuser”, ”secret”);
}



                              Additional note:
                              Yes, this test has no assertion.
                              Fundamental checks, such as
                              verifying navigation, are built into
                              the test infrastructure.
Additional note:
                          Sequence of steps to reach a state
                          where a fundamental login test
                          (smoke test) could be executed.

                          Fixing the dependency mess, the unit
                          tests, and adding a business layer
                          became an ongoing activity
        Creating new      (= outside the scope of this talk).
          databases
        with classified
         data is easy

                           Application
                          deployed to a           Deployment
                           server with            automated
                          known config




Start                                            Login test runs




                                                    GOAL
Work the system



    Import all objects                     See where it crashes




Drop all objects                                Add the missing object




    Add data to object                        Classify data




                           Document
                                                    flickr: Klearchos Kapoutsis
Additional note:
At the time of the conference, the
system had been automatically
deployed 181 times. In ½ year, that’s
roughly once a day. Given that manual
deployment took between 5-60
minutes, the time saved was 2 weeks.
Test framework   @Test


Flow/business    application.login(”testuser”, ”secret”);


Page/dialog      loginPage.enterUserName(”testuser”);
                 loginPage.enterPassword(”secret”);
                 loginPage.clickLoginButton();


Internals        webDriver.findElementBy(id(”text_user”))
                     .setText(”testuser”);
                 webDriver.findElementBy(id(”text_password”))
                     .setText(”secret”);
Our take aways and advice – Big picture

• Don’t be overwhelmed
• Black boxes in your environment make
  you feel uneasy and waste time
• Achieving testability proved to
  be a good guide
• After a while, the approach
  became second nature
Take aways – Details
• Using simple tools helped us save time
• End-to-end tests without controlling the
  database shouldn’t and didn’t work
• Record/playback didn’t work this time either
• Nobody asked about ”acceptance tests
  readable by the stakeholders”
However...

2012-10-22 16:16:31,528 ERROR [http-127.0.0.1-8989-2]
(SynchronizationRegistry.java:46) - Exception processing transaction
Synchronization after completion
java.lang.NullPointerException
at com.organization.system.TreeObject.isEquipment(TreeObject.java:34)




                                           Additional note:
                                           It doesn’t matter if you can get your
                                           test infrastructure right. Quality
                                           cannot be tested in. Spaghetti
                                           dependencies, poor unit test coverage
                                           and lack of business layer still were a
                                           problem.

Mais conteúdo relacionado

Mais procurados

Quality of Bug Reports in Open Source
Quality of Bug Reports in Open SourceQuality of Bug Reports in Open Source
Quality of Bug Reports in Open SourceThomas Zimmermann
 
Common primitives in Docker environments
Common primitives in Docker environmentsCommon primitives in Docker environments
Common primitives in Docker environmentsalexandru giurgiu
 
Continuous Delivery in the real world - techniques to reduce the developers b...
Continuous Delivery in the real world - techniques to reduce the developers b...Continuous Delivery in the real world - techniques to reduce the developers b...
Continuous Delivery in the real world - techniques to reduce the developers b...Nikolai Blackie
 
Q con shanghai2013-[黄舒泉]-[intel it openstack practice]
Q con shanghai2013-[黄舒泉]-[intel it openstack practice]Q con shanghai2013-[黄舒泉]-[intel it openstack practice]
Q con shanghai2013-[黄舒泉]-[intel it openstack practice]Michael Zhang
 
Microsoft SQL Server Testing Frameworks
Microsoft SQL Server Testing FrameworksMicrosoft SQL Server Testing Frameworks
Microsoft SQL Server Testing FrameworksMark Ginnebaugh
 
Nuxeo on the Cloud - Nuxeo World 2011
Nuxeo on the Cloud - Nuxeo World 2011Nuxeo on the Cloud - Nuxeo World 2011
Nuxeo on the Cloud - Nuxeo World 2011Stefane Fermigier
 
September 2010 - Arquillian
September 2010 - ArquillianSeptember 2010 - Arquillian
September 2010 - ArquillianJBug Italy
 
Slide share from betsy, edit 5370 group 2
Slide share from betsy, edit 5370 group 2Slide share from betsy, edit 5370 group 2
Slide share from betsy, edit 5370 group 2blharkey
 
Running productioninstance 1-localcopy
Running productioninstance 1-localcopyRunning productioninstance 1-localcopy
Running productioninstance 1-localcopyCloudBees
 
Delphix for DBAs by Jonathan Lewis
Delphix for DBAs by Jonathan LewisDelphix for DBAs by Jonathan Lewis
Delphix for DBAs by Jonathan LewisKyle Hailey
 
Agile Open Source Performance Test Workshop for Developers, Testers, IT Ops
Agile Open Source Performance Test Workshop for Developers, Testers, IT OpsAgile Open Source Performance Test Workshop for Developers, Testers, IT Ops
Agile Open Source Performance Test Workshop for Developers, Testers, IT OpsClever Moe
 
Webinar: Zing Vision: Answering your toughest production Java performance que...
Webinar: Zing Vision: Answering your toughest production Java performance que...Webinar: Zing Vision: Answering your toughest production Java performance que...
Webinar: Zing Vision: Answering your toughest production Java performance que...Azul Systems Inc.
 
Coding With JRebel - Java Forever Changed
Coding With JRebel - Java Forever ChangedCoding With JRebel - Java Forever Changed
Coding With JRebel - Java Forever ChangedElizabeth Quinn-Woods
 
Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1Kevin Sutter
 
Continuous delivery chernivcy
Continuous delivery chernivcyContinuous delivery chernivcy
Continuous delivery chernivcyVolodymyr Yelchev
 

Mais procurados (19)

Whipp q3 2008_sv
Whipp q3 2008_svWhipp q3 2008_sv
Whipp q3 2008_sv
 
Quality of Bug Reports in Open Source
Quality of Bug Reports in Open SourceQuality of Bug Reports in Open Source
Quality of Bug Reports in Open Source
 
Agile Testing Overview
Agile Testing OverviewAgile Testing Overview
Agile Testing Overview
 
Common primitives in Docker environments
Common primitives in Docker environmentsCommon primitives in Docker environments
Common primitives in Docker environments
 
Continuous Delivery in the real world - techniques to reduce the developers b...
Continuous Delivery in the real world - techniques to reduce the developers b...Continuous Delivery in the real world - techniques to reduce the developers b...
Continuous Delivery in the real world - techniques to reduce the developers b...
 
CloudBees
CloudBeesCloudBees
CloudBees
 
Q con shanghai2013-[黄舒泉]-[intel it openstack practice]
Q con shanghai2013-[黄舒泉]-[intel it openstack practice]Q con shanghai2013-[黄舒泉]-[intel it openstack practice]
Q con shanghai2013-[黄舒泉]-[intel it openstack practice]
 
Microsoft SQL Server Testing Frameworks
Microsoft SQL Server Testing FrameworksMicrosoft SQL Server Testing Frameworks
Microsoft SQL Server Testing Frameworks
 
Nuxeo on the Cloud - Nuxeo World 2011
Nuxeo on the Cloud - Nuxeo World 2011Nuxeo on the Cloud - Nuxeo World 2011
Nuxeo on the Cloud - Nuxeo World 2011
 
September 2010 - Arquillian
September 2010 - ArquillianSeptember 2010 - Arquillian
September 2010 - Arquillian
 
Slide share from betsy, edit 5370 group 2
Slide share from betsy, edit 5370 group 2Slide share from betsy, edit 5370 group 2
Slide share from betsy, edit 5370 group 2
 
Running productioninstance 1-localcopy
Running productioninstance 1-localcopyRunning productioninstance 1-localcopy
Running productioninstance 1-localcopy
 
Delphix for DBAs by Jonathan Lewis
Delphix for DBAs by Jonathan LewisDelphix for DBAs by Jonathan Lewis
Delphix for DBAs by Jonathan Lewis
 
Agile Open Source Performance Test Workshop for Developers, Testers, IT Ops
Agile Open Source Performance Test Workshop for Developers, Testers, IT OpsAgile Open Source Performance Test Workshop for Developers, Testers, IT Ops
Agile Open Source Performance Test Workshop for Developers, Testers, IT Ops
 
Webinar: Zing Vision: Answering your toughest production Java performance que...
Webinar: Zing Vision: Answering your toughest production Java performance que...Webinar: Zing Vision: Answering your toughest production Java performance que...
Webinar: Zing Vision: Answering your toughest production Java performance que...
 
Coding With JRebel - Java Forever Changed
Coding With JRebel - Java Forever ChangedCoding With JRebel - Java Forever Changed
Coding With JRebel - Java Forever Changed
 
Maven nutshell
Maven nutshellMaven nutshell
Maven nutshell
 
Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1Haj 4344-java se 9 and the application server-1
Haj 4344-java se 9 and the application server-1
 
Continuous delivery chernivcy
Continuous delivery chernivcyContinuous delivery chernivcy
Continuous delivery chernivcy
 

Semelhante a Testability for developers – Fighting a mess by making it testable

DevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroDevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroPaul Boos
 
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't SuckDeliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't SuckKevin Brockhoff
 
XebiaLabs, CloudBees, Puppet Labs Webinar Slides - IT Automation for the Mode...
XebiaLabs, CloudBees, Puppet Labs Webinar Slides - IT Automation for the Mode...XebiaLabs, CloudBees, Puppet Labs Webinar Slides - IT Automation for the Mode...
XebiaLabs, CloudBees, Puppet Labs Webinar Slides - IT Automation for the Mode...XebiaLabs
 
Five Ways Automation Has Increased Application Deployment and Changed Culture
Five Ways Automation Has Increased Application Deployment and Changed CultureFive Ways Automation Has Increased Application Deployment and Changed Culture
Five Ways Automation Has Increased Application Deployment and Changed CultureXebiaLabs
 
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Cωνσtantίnoς Giannoulis
 
Automated testing DrupalCamp in Asheville
Automated testing DrupalCamp in AshevilleAutomated testing DrupalCamp in Asheville
Automated testing DrupalCamp in AshevillePromet Source
 
Test-Driven Infrastructure with CloudFormation and Cucumber.
Test-Driven Infrastructure with CloudFormation and Cucumber. Test-Driven Infrastructure with CloudFormation and Cucumber.
Test-Driven Infrastructure with CloudFormation and Cucumber. Stelligent
 
A software monitoring framework for quality verification
A software monitoring framework for quality verificationA software monitoring framework for quality verification
A software monitoring framework for quality verificationDileepa Jayathilake
 
Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Enkitec
 
Test driven development for infrastructure as-a-code, the future trend_Gianfr...
Test driven development for infrastructure as-a-code, the future trend_Gianfr...Test driven development for infrastructure as-a-code, the future trend_Gianfr...
Test driven development for infrastructure as-a-code, the future trend_Gianfr...Katherine Golovinova
 
Jimwebber soa
Jimwebber soaJimwebber soa
Jimwebber soad0nn9n
 
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестамDSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестамSQALab
 
Easy Java Integration Testing with Testcontainers​
Easy Java Integration Testing with Testcontainers​Easy Java Integration Testing with Testcontainers​
Easy Java Integration Testing with Testcontainers​Payara
 
Releasing fast code - The DevOps approach
Releasing fast code - The DevOps approachReleasing fast code - The DevOps approach
Releasing fast code - The DevOps approachMichael Kopp
 
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxDSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxMikalai Alimenkou
 
Puppet overview
Puppet overviewPuppet overview
Puppet overviewjoshbeard
 
Webinar issues we_find_slideshare
Webinar issues we_find_slideshareWebinar issues we_find_slideshare
Webinar issues we_find_slideshareSOASTA
 
30 days or less: New Features to Production
30 days or less: New Features to Production30 days or less: New Features to Production
30 days or less: New Features to ProductionKarthik Gaekwad
 
OSCON 2012 OpenStack Automation and DevOps Best Practices
OSCON 2012 OpenStack Automation and DevOps Best PracticesOSCON 2012 OpenStack Automation and DevOps Best Practices
OSCON 2012 OpenStack Automation and DevOps Best PracticesMatt Ray
 
IT Agility: Rapid Application Development and Testing in the Cloud with CQ5 O...
IT Agility: Rapid Application Development and Testing in the Cloud with CQ5 O...IT Agility: Rapid Application Development and Testing in the Cloud with CQ5 O...
IT Agility: Rapid Application Development and Testing in the Cloud with CQ5 O...Day Software
 

Semelhante a Testability for developers – Fighting a mess by making it testable (20)

DevOps - Boldly Go for Distro
DevOps - Boldly Go for DistroDevOps - Boldly Go for Distro
DevOps - Boldly Go for Distro
 
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't SuckDeliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
Deliver Faster with BDD/TDD - Designing Automated Tests That Don't Suck
 
XebiaLabs, CloudBees, Puppet Labs Webinar Slides - IT Automation for the Mode...
XebiaLabs, CloudBees, Puppet Labs Webinar Slides - IT Automation for the Mode...XebiaLabs, CloudBees, Puppet Labs Webinar Slides - IT Automation for the Mode...
XebiaLabs, CloudBees, Puppet Labs Webinar Slides - IT Automation for the Mode...
 
Five Ways Automation Has Increased Application Deployment and Changed Culture
Five Ways Automation Has Increased Application Deployment and Changed CultureFive Ways Automation Has Increased Application Deployment and Changed Culture
Five Ways Automation Has Increased Application Deployment and Changed Culture
 
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
Lessons Learned in Software Development: QA Infrastructure – Maintaining Rob...
 
Automated testing DrupalCamp in Asheville
Automated testing DrupalCamp in AshevilleAutomated testing DrupalCamp in Asheville
Automated testing DrupalCamp in Asheville
 
Test-Driven Infrastructure with CloudFormation and Cucumber.
Test-Driven Infrastructure with CloudFormation and Cucumber. Test-Driven Infrastructure with CloudFormation and Cucumber.
Test-Driven Infrastructure with CloudFormation and Cucumber.
 
A software monitoring framework for quality verification
A software monitoring framework for quality verificationA software monitoring framework for quality verification
A software monitoring framework for quality verification
 
Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12Kelly potvin nosurprises_odtug_oow12
Kelly potvin nosurprises_odtug_oow12
 
Test driven development for infrastructure as-a-code, the future trend_Gianfr...
Test driven development for infrastructure as-a-code, the future trend_Gianfr...Test driven development for infrastructure as-a-code, the future trend_Gianfr...
Test driven development for infrastructure as-a-code, the future trend_Gianfr...
 
Jimwebber soa
Jimwebber soaJimwebber soa
Jimwebber soa
 
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестамDSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
 
Easy Java Integration Testing with Testcontainers​
Easy Java Integration Testing with Testcontainers​Easy Java Integration Testing with Testcontainers​
Easy Java Integration Testing with Testcontainers​
 
Releasing fast code - The DevOps approach
Releasing fast code - The DevOps approachReleasing fast code - The DevOps approach
Releasing fast code - The DevOps approach
 
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxDSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
 
Puppet overview
Puppet overviewPuppet overview
Puppet overview
 
Webinar issues we_find_slideshare
Webinar issues we_find_slideshareWebinar issues we_find_slideshare
Webinar issues we_find_slideshare
 
30 days or less: New Features to Production
30 days or less: New Features to Production30 days or less: New Features to Production
30 days or less: New Features to Production
 
OSCON 2012 OpenStack Automation and DevOps Best Practices
OSCON 2012 OpenStack Automation and DevOps Best PracticesOSCON 2012 OpenStack Automation and DevOps Best Practices
OSCON 2012 OpenStack Automation and DevOps Best Practices
 
IT Agility: Rapid Application Development and Testing in the Cloud with CQ5 O...
IT Agility: Rapid Application Development and Testing in the Cloud with CQ5 O...IT Agility: Rapid Application Development and Testing in the Cloud with CQ5 O...
IT Agility: Rapid Application Development and Testing in the Cloud with CQ5 O...
 

Mais de Alexander Tarlinder

Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with SpockAlexander Tarlinder
 
Dealing with combinatorial explosions and boring tests
Dealing with combinatorial explosions and boring testsDealing with combinatorial explosions and boring tests
Dealing with combinatorial explosions and boring testsAlexander Tarlinder
 
Agile Testing – Is it for me and how are others doing it?
Agile Testing – Is it for me and how are others doing it?Agile Testing – Is it for me and how are others doing it?
Agile Testing – Is it for me and how are others doing it?Alexander Tarlinder
 
Developer testing - Love it or hate it (in Swedish)
Developer testing - Love it or hate it (in Swedish)Developer testing - Love it or hate it (in Swedish)
Developer testing - Love it or hate it (in Swedish)Alexander Tarlinder
 
Being good at waiting - Using Selenium to test Ajax-intensive pages
Being good at waiting - Using Selenium to test Ajax-intensive pages Being good at waiting - Using Selenium to test Ajax-intensive pages
Being good at waiting - Using Selenium to test Ajax-intensive pages Alexander Tarlinder
 

Mais de Alexander Tarlinder (6)

Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with Spock
 
Dealing with combinatorial explosions and boring tests
Dealing with combinatorial explosions and boring testsDealing with combinatorial explosions and boring tests
Dealing with combinatorial explosions and boring tests
 
Testability for Developers
Testability for DevelopersTestability for Developers
Testability for Developers
 
Agile Testing – Is it for me and how are others doing it?
Agile Testing – Is it for me and how are others doing it?Agile Testing – Is it for me and how are others doing it?
Agile Testing – Is it for me and how are others doing it?
 
Developer testing - Love it or hate it (in Swedish)
Developer testing - Love it or hate it (in Swedish)Developer testing - Love it or hate it (in Swedish)
Developer testing - Love it or hate it (in Swedish)
 
Being good at waiting - Using Selenium to test Ajax-intensive pages
Being good at waiting - Using Selenium to test Ajax-intensive pages Being good at waiting - Using Selenium to test Ajax-intensive pages
Being good at waiting - Using Selenium to test Ajax-intensive pages
 

Testability for developers – Fighting a mess by making it testable

  • 1. Testability for developers Fighting a mess by making it testable XP Days Ukraine 2012 Alexander Tarnowski
  • 2. Additional note: This presentation has been slightly adjusted after the conference. Some images have been removed and some notes have been added to provide context.
  • 3. Ongoing project alexander.tarnowski@crisp.se alexander_tar Blog blog.crisp.se/author/alexandertarnowski www www.techbookreader.com http://leanpub.com/developer_testing
  • 4. My system’s dependencies are like spaghetti My system is ruled by a database It’s a ritual to deploy my system My system doesn’t have a business layer My system has few and poor unit tests My system’s end-to-end tests don’t work
  • 5. Frontend Legend EWC = Enterprise-wide componment Front = Depends on end = Packaged into WS developer pack from 2004 ”Enterprise-wide” component Backend EWC Back core end core EWC Back shared end shared Enterprise message bus library Joker: flickr: GoShows
  • 6. A number of data sources Alternative message queue implementation Application’s config files ? Parts of the application Message bus library flickr: Andrew Coulter Enright
  • 7. One Database to rule them all, One Database to find them, One Database to bring them all and in the darkness bind them
  • 8. Additional note: A lengthy manual deployment script that’s not up-to-date has a striking resemblance to hieroglyphs. flickr: rfzappala
  • 9. Good idea Bad idea Database Additional note: Some frameworks try really hard to provide persistence as close to the view as possible. When is that a good idea?
  • 10.
  • 11. Είχαν τεςςαρϊν μεταγλωτίςει ασ ςαν, αλφα εκτελείται δεν τι. Από κα χρόνου χαμθλόσ ποςοςτό. Γειτονιάσ εργαηόμενων να πεσ επενδυτισ το. Χάοσ προςεκτικά δε ςτθ. Όρο πάρα ιδιαίτερα αν, όςο το πετοφν γνωρίηει. Το όςο γραφικά δθμιουργίεσ χαρακτθριςτικό, όλα μθ ζργων περίπου. Διακοπι οζλεγχοσ χαρακτθριςτικϊν να όχι, μθ Ήδθ ζτςι Thread.sleep(3000); χρόνου κα. Στο με όταν λοιπόν ςθμαντικόσ, ζρκει ςχεδιαςτισ ιδθ τι. Ασ τθν γειτονιάσ αγοράηοντασ. Ασ πετοφν αποτελζςει κα μπουν προςλάμβανεσ, πιο ωσ ςτθν προςπακοφν. Thread.sleep(3000); Πω δουλζψει προςεκτικά χαρακτθριςτικϊν ςου, ζςτελνε φακζλουσ ανακλφψεισ τι νζα. Ατόμου αποφάςιςε που τι, προςλάμβανεσ των, ποςοςτό επιτίκενται το ναι. Πω ερωτιςεισ χρειάηονται λεσ, βιμα πάρεισ κρατάει να κλπ. Τθν ξεχειλίηει. Τθν πετάνε χαμθλόσ χαρακτθριςτικϊν να, δε κρατιςουν προβλθματικι μθν. Τθ κφκλο κανείσ απίςτευτα ϊρα, αλγόρικμου προβλιματα αντιλιφκθκαν. Υόρκθ καρζκλα λιγότερο να ότι, τότε μπουν κρατάει πιο οι. Τι ςου γραφικά αρπάηεισ δουλεφουν. Ώσ βακμό δθμιουργίεσ, μια μα κζματα διοικθτικό, δε πελάτεσ δυςτυχϊσ ςυγχρόνωσ ςασ. Κι τουσ δίνοντασ λεσ. Νζεσ εξαρτάται οι όχι, ϊσ ξζχαςε προϊόντα ότι. Thread.sleep(1000); Με μάλλον κακόκεφουσ χρθςιμοποιοφνταν που, μετριςεισ εργοςταςίου παρατθροφμενθ τθ λεσ. Λοιπόν ναί να. Αν ιδθ νζων εκτόσ, Thread.sleep(2000); ςασ άρκρων χριματα χρθςιμοποιιςει μθ. Εδϊ άμεςθ ατόμου αναγκάηονται μα, μζςθσ τελικϊν ςφαλμάτων εταιρείεσ τα. Thread.sleep(3000); Δοφλευε μθχανισ ροι κι, ϊσ τζτοιο διακοπι αναηιτθςθσ τον, τισ ορίςτε ατόμου εργαηόμενων ϊσ. Όχι λοιπόν κρατάει κα. Μάκε όχι Additional note: Long record/playback tests with incorrect handling of asynchronicity tend to look like Greek after a while. flickr: bunky’s pickle
  • 12. Dependency spaghetti Few and poor Unknown app server unit tests configuration Data base Where do we start No business layer Record/playback (with timing issues) Manual deployment One database
  • 13. What Why New code unit-tested We’re in a hole and we don’t want to dig deeper Create a business layer Quality in the long run Automated end-to-end • Initiate change tests for happy paths • ”Quick” wins
  • 14. @Test public void aUserCanLogIn() { application.login(”testuser”, ”secret”); } Additional note: Yes, this test has no assertion. Fundamental checks, such as verifying navigation, are built into the test infrastructure.
  • 15. Additional note: Sequence of steps to reach a state where a fundamental login test (smoke test) could be executed. Fixing the dependency mess, the unit tests, and adding a business layer became an ongoing activity Creating new (= outside the scope of this talk). databases with classified data is easy Application deployed to a Deployment server with automated known config Start Login test runs GOAL
  • 16. Work the system Import all objects See where it crashes Drop all objects Add the missing object Add data to object Classify data Document flickr: Klearchos Kapoutsis
  • 17. Additional note: At the time of the conference, the system had been automatically deployed 181 times. In ½ year, that’s roughly once a day. Given that manual deployment took between 5-60 minutes, the time saved was 2 weeks.
  • 18. Test framework @Test Flow/business application.login(”testuser”, ”secret”); Page/dialog loginPage.enterUserName(”testuser”); loginPage.enterPassword(”secret”); loginPage.clickLoginButton(); Internals webDriver.findElementBy(id(”text_user”)) .setText(”testuser”); webDriver.findElementBy(id(”text_password”)) .setText(”secret”);
  • 19. Our take aways and advice – Big picture • Don’t be overwhelmed • Black boxes in your environment make you feel uneasy and waste time • Achieving testability proved to be a good guide • After a while, the approach became second nature
  • 20. Take aways – Details • Using simple tools helped us save time • End-to-end tests without controlling the database shouldn’t and didn’t work • Record/playback didn’t work this time either • Nobody asked about ”acceptance tests readable by the stakeholders”
  • 21. However... 2012-10-22 16:16:31,528 ERROR [http-127.0.0.1-8989-2] (SynchronizationRegistry.java:46) - Exception processing transaction Synchronization after completion java.lang.NullPointerException at com.organization.system.TreeObject.isEquipment(TreeObject.java:34) Additional note: It doesn’t matter if you can get your test infrastructure right. Quality cannot be tested in. Spaghetti dependencies, poor unit test coverage and lack of business layer still were a problem.

Notas do Editor

  1. 161/6 months =~ once a day161 * (5-60 minutes/deployment) =~ 2 weeks
  2. DonkeyHotey
  3. You Can’t test quality in2012-10-22 16:16:31,528 ERROR [http-127.0.0.1-8989-2] (SynchronizationRegistry.java:46) - Exception processing transaction Synchronization after completionjava.lang.NullPointerExceptionat com.organization.system.TreeObject.isEquipment(TreeObject.java:34)