SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
Does my test script smell?
    Detect, fix and prevent
  common maintenance issues
     with automated tests



          Martin Gijsen
    Test automation architect

      TESTWAREZ 2009
             © 2009
Overview
●   Maintenance of automated tests
●   Test script smell
●   Common maintenance issues
●   Conclusion
●   Q&A
Automated testing in practice

                                total
                                cost /
                                effort

 About 2/3 of all test                           3
                                                        2
automation projects                                      1
fail sooner or later
– Brian LeSuer
(testing experience magazine,
December 2008, page 47)
                                                                      time
                                     1. manual testing
                                     2. effective automated testing
                                     3. less effective automated testing
Maintenance of automated tests
●   The Record & Playback approach does not work
●   Total maintenance depends on:
    ●   Number of changes
    ●   Maintenance sensitivity (does change affect test?)
    ●   Maintainability (how much effort)
●   For continuity of benefits, focus on:
    ●   3 R's: Tests must be easy to write, review and revise
    ●   Maintainability and maintenance sensitivity
Test script smell (1)
●   Test script smell is derived from 'code smell'
●   Wikipedia:
    ●   In computer programming, code smell is any
        symptom in the source code of a program that
        possibly indicates a deeper problem.
    ●   Code refactoring is the process of changing a
        computer program's internal structure without
        modifying its external functional behavior or
        existing functionality.
Test script smell (2)
●   Test script smell is any symptom in an
    automated test that possibly indicates a
    deeper problem.
●   Test refactoring is the process of changing
    the internal structure of an automated test
    without modifying its external functionality.
●   Most test script issues increase maintenance
●   Focus on the average tester!
Common maintenance issues
●   Unreadable tests
●   Long test cases
●   Repeating sequences
●   Interface details in test cases
●   Tooling details in test cases
●   Literal constants in test cases


    Examples will use the freeware ETA Framework
A Selenium test (Java)
Selenium selenium = new DefaultSelenium (“localhost”, 4444, “*firefox”, “http://www.google.com”);
selenium.start ();


selenium.open (“/”);
if (selenium.getTitle ().indexOf (“Google”) < 0) {
    reportError (“an error message”);
}


selenium.type (“q”, “the quick brown fox jumps over the lazy dog”);
selenium.click (“btnG”);
if (selenium.getTitle ().indexOf (“the quick brown fox jumps over the lazy dog”) < 0) {
    reportError (“an error message”);
}


selenium.click (“link=YouTube”);
A keyword based test
new DefaultSelenium      localhost        4444    *firefox   http://www.google.com


start


open                     /




type
             !
getTitle ().indexOf (“Google”)


                         q                the quick brown fox jumps over the lazy dog


click                    btnG


getTitle ().indexOf (“the quick brown fox jumps over the lazy dog”)


click                    link=YouTube
Interface details removed
new DefaultSelenium       localhost        4444 *firefox     http://www.google.com


start


open                      /


getTitle ().indexOf (“Google”)




                                 !
type                      ?queryField      the quick brown fox jumps over the lazy dog


click                     ?searchButton


getTitle ().indexOf (“the quick brown fox jumps over the lazy dog”)


click                     link=YouTube
Tooling details removed

        !
                   type             URL
open browser       firefox          www.google.com


open               /




type
        !
check page title   Google


                   ?queryField      the quick brown fox jumps over the lazy dog


click              ?searchButton




        !
check page title   the quick brown fox jumps over the lazy dog


select link        YouTube
Abstraction level increased
                type            URL
open browser    firefox         www.google.com


                web page        title
open page       /               Google


                search string
search          the quick brown fox jumps over the lazy dog


                link text
select result   YouTube
The automated test
    Test case
     Test case         Test analyst




Scripted procedures
 Scripted procedures   Test analyst / Developer




   Source code
    Source code        Developer




    Application
     Application
Conclusion
●   Abstraction is the key to low maintenance
●   For easy maintenance:
    ●   Make tests readable (to your manager?)
    ●   Make tests compact (high abstraction level)
    ●   Remove interface + tooling details (implicit or config)
    ●   Use symbolic constants
●   Define test instructions top down
●   Test automation is software engineering
●   Example test engines: ETA Framework & FIT
Q&A




?
Main sheet & configuration sheet
Main sheet:                       name
                run sheet         configuration
                run sheet         procedures


                                  type            URL
                open browser      firefox         www.google.com


                                  name
                run sheet         test cases



Config sheet:                       name            value
                define constant     queryField      q
                define constant     searchButton    btnG
Procedures
                   name         Param 1   Param 2
define procedure   open page    url       pageTitle


                   url
open URL           ?url


                   title
check page title   ?pageTitle


end procedure
Procedures
                   name            Param 1
define procedure   search          searchString


                   input field     value
type               ?queryField     ?searchString


                   item name
click              ?searchButton
                                                   Configuration sheet

                   title
check page title   ?searchString


end procedure
The test (case)
                  identification   description
begin test case   google1          A Google test


                  web page         title
open page         /                Google


                  search string
search            the quick brown fox jumps over the lazy dog


                  link text
select result     YouTube


end test case



close browser

Contenu connexe

Tendances

20111018 boost and gtest
20111018 boost and gtest20111018 boost and gtest
20111018 boost and gtest
Will Shen
 
Presentation_C++UnitTest
Presentation_C++UnitTestPresentation_C++UnitTest
Presentation_C++UnitTest
Raihan Masud
 

Tendances (19)

Modern Python Testing
Modern Python TestingModern Python Testing
Modern Python Testing
 
Principles and patterns for test driven development
Principles and patterns for test driven developmentPrinciples and patterns for test driven development
Principles and patterns for test driven development
 
Unit Test Your Database
Unit Test Your DatabaseUnit Test Your Database
Unit Test Your Database
 
Unit Test + Functional Programming = Love
Unit Test + Functional Programming = LoveUnit Test + Functional Programming = Love
Unit Test + Functional Programming = Love
 
20111018 boost and gtest
20111018 boost and gtest20111018 boost and gtest
20111018 boost and gtest
 
Unit testing plugins: The 5 W's and an H
Unit testing plugins: The 5 W's and an HUnit testing plugins: The 5 W's and an H
Unit testing plugins: The 5 W's and an H
 
JUnit 5 - The Next Generation
JUnit 5 - The Next GenerationJUnit 5 - The Next Generation
JUnit 5 - The Next Generation
 
Software Engineering - RS3
Software Engineering - RS3Software Engineering - RS3
Software Engineering - RS3
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylight
 
OSGi Applications Testing - André Elia Assad, System Engineer, Cesar
OSGi Applications Testing - André Elia Assad, System Engineer, CesarOSGi Applications Testing - André Elia Assad, System Engineer, Cesar
OSGi Applications Testing - André Elia Assad, System Engineer, Cesar
 
What is new in JUnit5
What is new in JUnit5What is new in JUnit5
What is new in JUnit5
 
JUnit 5: What's New and What's Coming - Spring I/O 2019
JUnit 5: What's New and What's Coming - Spring I/O 2019JUnit 5: What's New and What's Coming - Spring I/O 2019
JUnit 5: What's New and What's Coming - Spring I/O 2019
 
Test Driven Development - The art of fearless programming
Test Driven Development - The art of fearless programmingTest Driven Development - The art of fearless programming
Test Driven Development - The art of fearless programming
 
Python Testing Fundamentals
Python Testing FundamentalsPython Testing Fundamentals
Python Testing Fundamentals
 
Python unit testing
Python unit testingPython unit testing
Python unit testing
 
Automated testing in Python and beyond
Automated testing in Python and beyondAutomated testing in Python and beyond
Automated testing in Python and beyond
 
2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier2016 10-04: tdd++: tdd made easier
2016 10-04: tdd++: tdd made easier
 
Presentation_C++UnitTest
Presentation_C++UnitTestPresentation_C++UnitTest
Presentation_C++UnitTest
 
VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)
 

Similaire à Does my test script smell?

Implementing Test Automation in Agile Projects
Implementing Test Automation in Agile ProjectsImplementing Test Automation in Agile Projects
Implementing Test Automation in Agile Projects
Michael Palotas
 
Making the most of your Test Suite
Making the most of your Test SuiteMaking the most of your Test Suite
Making the most of your Test Suite
ericholscher
 

Similaire à Does my test script smell? (20)

Rich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFXRich GUI Testing: Swing and JavaFX
Rich GUI Testing: Swing and JavaFX
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
 
Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023Getting Started with Test-Driven Development at Longhorn PHP 2023
Getting Started with Test-Driven Development at Longhorn PHP 2023
 
Automated Unit Testing
Automated Unit TestingAutomated Unit Testing
Automated Unit Testing
 
How do you tame a big ball of mud? One test at a time.
How do you tame a big ball of mud? One test at a time.How do you tame a big ball of mud? One test at a time.
How do you tame a big ball of mud? One test at a time.
 
Implementing Test Automation in Agile Projects
Implementing Test Automation in Agile ProjectsImplementing Test Automation in Agile Projects
Implementing Test Automation in Agile Projects
 
Ui Testing with Ghost Inspector
Ui Testing with Ghost InspectorUi Testing with Ghost Inspector
Ui Testing with Ghost Inspector
 
Implementing Test Automation in Agile Projects
Implementing Test Automation in Agile ProjectsImplementing Test Automation in Agile Projects
Implementing Test Automation in Agile Projects
 
JAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & JasmineJAVASCRIPT Test Driven Development & Jasmine
JAVASCRIPT Test Driven Development & Jasmine
 
Getting Started with Test-Driven Development at PHPtek 2023
Getting Started with Test-Driven Development at PHPtek 2023Getting Started with Test-Driven Development at PHPtek 2023
Getting Started with Test-Driven Development at PHPtek 2023
 
The Evolution of Development Testing
The Evolution of Development TestingThe Evolution of Development Testing
The Evolution of Development Testing
 
Making the most of your Test Suite
Making the most of your Test SuiteMaking the most of your Test Suite
Making the most of your Test Suite
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django Applications
 
Property Based Testing in PHP
Property Based Testing in PHPProperty Based Testing in PHP
Property Based Testing in PHP
 
Hack@macs 2014 test driven development & pair programing
Hack@macs 2014 test driven development & pair programingHack@macs 2014 test driven development & pair programing
Hack@macs 2014 test driven development & pair programing
 
Google, quality and you
Google, quality and youGoogle, quality and you
Google, quality and you
 
03 test specification and execution
03   test specification and execution03   test specification and execution
03 test specification and execution
 

Does my test script smell?

  • 1. Does my test script smell? Detect, fix and prevent common maintenance issues with automated tests Martin Gijsen Test automation architect TESTWAREZ 2009 © 2009
  • 2. Overview ● Maintenance of automated tests ● Test script smell ● Common maintenance issues ● Conclusion ● Q&A
  • 3. Automated testing in practice total cost / effort About 2/3 of all test 3 2 automation projects 1 fail sooner or later – Brian LeSuer (testing experience magazine, December 2008, page 47) time 1. manual testing 2. effective automated testing 3. less effective automated testing
  • 4. Maintenance of automated tests ● The Record & Playback approach does not work ● Total maintenance depends on: ● Number of changes ● Maintenance sensitivity (does change affect test?) ● Maintainability (how much effort) ● For continuity of benefits, focus on: ● 3 R's: Tests must be easy to write, review and revise ● Maintainability and maintenance sensitivity
  • 5. Test script smell (1) ● Test script smell is derived from 'code smell' ● Wikipedia: ● In computer programming, code smell is any symptom in the source code of a program that possibly indicates a deeper problem. ● Code refactoring is the process of changing a computer program's internal structure without modifying its external functional behavior or existing functionality.
  • 6. Test script smell (2) ● Test script smell is any symptom in an automated test that possibly indicates a deeper problem. ● Test refactoring is the process of changing the internal structure of an automated test without modifying its external functionality. ● Most test script issues increase maintenance ● Focus on the average tester!
  • 7. Common maintenance issues ● Unreadable tests ● Long test cases ● Repeating sequences ● Interface details in test cases ● Tooling details in test cases ● Literal constants in test cases Examples will use the freeware ETA Framework
  • 8. A Selenium test (Java) Selenium selenium = new DefaultSelenium (“localhost”, 4444, “*firefox”, “http://www.google.com”); selenium.start (); selenium.open (“/”); if (selenium.getTitle ().indexOf (“Google”) < 0) { reportError (“an error message”); } selenium.type (“q”, “the quick brown fox jumps over the lazy dog”); selenium.click (“btnG”); if (selenium.getTitle ().indexOf (“the quick brown fox jumps over the lazy dog”) < 0) { reportError (“an error message”); } selenium.click (“link=YouTube”);
  • 9. A keyword based test new DefaultSelenium localhost 4444 *firefox http://www.google.com start open / type ! getTitle ().indexOf (“Google”) q the quick brown fox jumps over the lazy dog click btnG getTitle ().indexOf (“the quick brown fox jumps over the lazy dog”) click link=YouTube
  • 10. Interface details removed new DefaultSelenium localhost 4444 *firefox http://www.google.com start open / getTitle ().indexOf (“Google”) ! type ?queryField the quick brown fox jumps over the lazy dog click ?searchButton getTitle ().indexOf (“the quick brown fox jumps over the lazy dog”) click link=YouTube
  • 11. Tooling details removed ! type URL open browser firefox www.google.com open / type ! check page title Google ?queryField the quick brown fox jumps over the lazy dog click ?searchButton ! check page title the quick brown fox jumps over the lazy dog select link YouTube
  • 12. Abstraction level increased type URL open browser firefox www.google.com web page title open page / Google search string search the quick brown fox jumps over the lazy dog link text select result YouTube
  • 13. The automated test Test case Test case Test analyst Scripted procedures Scripted procedures Test analyst / Developer Source code Source code Developer Application Application
  • 14. Conclusion ● Abstraction is the key to low maintenance ● For easy maintenance: ● Make tests readable (to your manager?) ● Make tests compact (high abstraction level) ● Remove interface + tooling details (implicit or config) ● Use symbolic constants ● Define test instructions top down ● Test automation is software engineering ● Example test engines: ETA Framework & FIT
  • 15. Q&A ?
  • 16. Main sheet & configuration sheet Main sheet: name run sheet configuration run sheet procedures type URL open browser firefox www.google.com name run sheet test cases Config sheet: name value define constant queryField q define constant searchButton btnG
  • 17. Procedures name Param 1 Param 2 define procedure open page url pageTitle url open URL ?url title check page title ?pageTitle end procedure
  • 18. Procedures name Param 1 define procedure search searchString input field value type ?queryField ?searchString item name click ?searchButton Configuration sheet title check page title ?searchString end procedure
  • 19. The test (case) identification description begin test case google1 A Google test web page title open page / Google search string search the quick brown fox jumps over the lazy dog link text select result YouTube end test case close browser