SlideShare una empresa de Scribd logo
1 de 13
Descargar para leer sin conexión
Restructuring Unit Tests with
        TestSurgeon
          Pablo Estefó
         paestefo@dcc.uchile.cl

         Undergrad Student
         University of Chile


                                  Programming Languages and Environments for
                                  Intelligent, Adaptable and Distributed systems
Why restructuring unit tests?
Unit tests are added when new features are
added

Large amount of unit tests
  – Long test execution
  – Maintenance issues
  – A trivial bug may invalidate many tests
My approach: TestSurgeon
TestSurgeon is a profiler for unit tests

 Monitors execution of unit tests

 Collect data on what is being tested and how

 Provides
  – Test Similarity metric
  – Visualization
How does it work?
1) Pick a test method from a large unit tests
   (red test)

2) TestSurgeon ranks similar tests (blue test)

3) Visualize the tests execution and their
   differences
Test Execution Blueprint
                              methods
Called by Red and Blue test

Called by Blue test

Called by Red test



                                        a base
                                         class
Scenario #1: Defining Fixture Initialization

  Two test methods in the same unit test

  Each test define its own test scenario and they are
 similar
Example: Scenario #1
MOFormsBuilderTest>>testElementAt (Red test)
MOFormsBuilderTest>>testDisplaying (Blue test)
Example: Scenario #1
          MOFormsBuilderTest>>testElementAt (Red test)
          MOFormsBuilderTest>>testDisplaying (Blue test)




Solution:
Move what calls the yellow portion in a
setUp method => test size reduction
Scenario #2: Discarding superfluous test
                     method
Small portions of blue or red but not both

Yellow, large and squared shaped methods
Example: Scenario #2
MOLayoutTest>>testHorizontalLineLayout (Red test)
MOViewRendererTest>>testCenter (Blue test)
Example: Scenario #2
          MOLayoutTest>>testHorizontalLineLayout (Red test)
          MOViewRendererTest>>testCenter (Blue test)




Solution:
Do not consider the blue test for frequent testing
Test Surgeon

 Profiler for unit tests
 Useful to spot differences
 Help to restructure tests


                              Future Work: More accurate
                              comparison of execution

                                Comparing groups of tests
                                State of object receivers
                                Message arguments
                                Side effect
                                Line coverage
|𝑇 𝑟 ∩ 𝑇 𝑏 |
   𝑆𝑖𝑚𝑖𝑙𝑎𝑟𝑖𝑡𝑦 𝑡 𝑟 , 𝑡 𝑏   =
                            |𝑇 𝑟 ∪ 𝑇 𝑏 |




Pablo Estefó - paestefo@dcc.uchile.cl

Más contenido relacionado

Similar a Restructuring Unit Tests with TestSurgeon - ICSE 2012

A software fault localization technique based on program mutations
A software fault localization technique based on program mutationsA software fault localization technique based on program mutations
A software fault localization technique based on program mutations
Tao He
 
Principles of design of experiments (doe)20 5-2014
Principles of  design of experiments (doe)20 5-2014Principles of  design of experiments (doe)20 5-2014
Principles of design of experiments (doe)20 5-2014
Awad Albalwi
 
A PARTICLE SWARM OPTIMIZATION TECHNIQUE FOR GENERATING PAIRWISE TEST CASES
A PARTICLE SWARM OPTIMIZATION TECHNIQUE FOR GENERATING PAIRWISE TEST CASESA PARTICLE SWARM OPTIMIZATION TECHNIQUE FOR GENERATING PAIRWISE TEST CASES
A PARTICLE SWARM OPTIMIZATION TECHNIQUE FOR GENERATING PAIRWISE TEST CASES
Kula Sekhar Reddy Yerraguntla
 

Similar a Restructuring Unit Tests with TestSurgeon - ICSE 2012 (20)

Testing
TestingTesting
Testing
 
Configuration Navigation Analysis Model for Regression Test Case Prioritization
Configuration Navigation Analysis Model for Regression Test Case PrioritizationConfiguration Navigation Analysis Model for Regression Test Case Prioritization
Configuration Navigation Analysis Model for Regression Test Case Prioritization
 
A software fault localization technique based on program mutations
A software fault localization technique based on program mutationsA software fault localization technique based on program mutations
A software fault localization technique based on program mutations
 
Chapter 3 SOFTWARE TESTING PROCESS
Chapter 3 SOFTWARE TESTING PROCESSChapter 3 SOFTWARE TESTING PROCESS
Chapter 3 SOFTWARE TESTING PROCESS
 
Principles of design of experiments (doe)20 5-2014
Principles of  design of experiments (doe)20 5-2014Principles of  design of experiments (doe)20 5-2014
Principles of design of experiments (doe)20 5-2014
 
Testing
TestingTesting
Testing
 
SAIConference_PAPER
SAIConference_PAPERSAIConference_PAPER
SAIConference_PAPER
 
Specification based or black box techniques
Specification based or black box techniquesSpecification based or black box techniques
Specification based or black box techniques
 
A PARTICLE SWARM OPTIMIZATION TECHNIQUE FOR GENERATING PAIRWISE TEST CASES
A PARTICLE SWARM OPTIMIZATION TECHNIQUE FOR GENERATING PAIRWISE TEST CASESA PARTICLE SWARM OPTIMIZATION TECHNIQUE FOR GENERATING PAIRWISE TEST CASES
A PARTICLE SWARM OPTIMIZATION TECHNIQUE FOR GENERATING PAIRWISE TEST CASES
 
Improving the Sensitivity of Online Controlled Experiments by Utilizing Pre-E...
Improving the Sensitivity of Online Controlled Experiments by Utilizing Pre-E...Improving the Sensitivity of Online Controlled Experiments by Utilizing Pre-E...
Improving the Sensitivity of Online Controlled Experiments by Utilizing Pre-E...
 
SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
 
Orthogonal array approach a case study
Orthogonal array approach   a case studyOrthogonal array approach   a case study
Orthogonal array approach a case study
 
SSBSE 2020 keynote
SSBSE 2020 keynoteSSBSE 2020 keynote
SSBSE 2020 keynote
 
Test design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniquesTest design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniques
 
Peter Zimmerer - Passion For Testing, By Examples - EuroSTAR 2010
Peter Zimmerer - Passion For Testing, By Examples - EuroSTAR 2010Peter Zimmerer - Passion For Testing, By Examples - EuroSTAR 2010
Peter Zimmerer - Passion For Testing, By Examples - EuroSTAR 2010
 
Presentation on supervised learning
Presentation on supervised learningPresentation on supervised learning
Presentation on supervised learning
 
Prediction Of Bioactivity From Chemical Structure
Prediction Of Bioactivity From Chemical StructurePrediction Of Bioactivity From Chemical Structure
Prediction Of Bioactivity From Chemical Structure
 
software engineering-best placement guarentee
software engineering-best placement guarenteesoftware engineering-best placement guarentee
software engineering-best placement guarentee
 
Testing ppt
Testing pptTesting ppt
Testing ppt
 
Software testing- an introduction
Software testing- an introductionSoftware testing- an introduction
Software testing- an introduction
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

Restructuring Unit Tests with TestSurgeon - ICSE 2012

  • 1. Restructuring Unit Tests with TestSurgeon Pablo Estefó paestefo@dcc.uchile.cl Undergrad Student University of Chile Programming Languages and Environments for Intelligent, Adaptable and Distributed systems
  • 2. Why restructuring unit tests? Unit tests are added when new features are added Large amount of unit tests – Long test execution – Maintenance issues – A trivial bug may invalidate many tests
  • 3. My approach: TestSurgeon TestSurgeon is a profiler for unit tests Monitors execution of unit tests Collect data on what is being tested and how Provides – Test Similarity metric – Visualization
  • 4. How does it work? 1) Pick a test method from a large unit tests (red test) 2) TestSurgeon ranks similar tests (blue test) 3) Visualize the tests execution and their differences
  • 5. Test Execution Blueprint methods Called by Red and Blue test Called by Blue test Called by Red test a base class
  • 6. Scenario #1: Defining Fixture Initialization Two test methods in the same unit test Each test define its own test scenario and they are similar
  • 7. Example: Scenario #1 MOFormsBuilderTest>>testElementAt (Red test) MOFormsBuilderTest>>testDisplaying (Blue test)
  • 8. Example: Scenario #1 MOFormsBuilderTest>>testElementAt (Red test) MOFormsBuilderTest>>testDisplaying (Blue test) Solution: Move what calls the yellow portion in a setUp method => test size reduction
  • 9. Scenario #2: Discarding superfluous test method Small portions of blue or red but not both Yellow, large and squared shaped methods
  • 10. Example: Scenario #2 MOLayoutTest>>testHorizontalLineLayout (Red test) MOViewRendererTest>>testCenter (Blue test)
  • 11. Example: Scenario #2 MOLayoutTest>>testHorizontalLineLayout (Red test) MOViewRendererTest>>testCenter (Blue test) Solution: Do not consider the blue test for frequent testing
  • 12. Test Surgeon Profiler for unit tests Useful to spot differences Help to restructure tests Future Work: More accurate comparison of execution Comparing groups of tests State of object receivers Message arguments Side effect Line coverage
  • 13. |𝑇 𝑟 ∩ 𝑇 𝑏 | 𝑆𝑖𝑚𝑖𝑙𝑎𝑟𝑖𝑡𝑦 𝑡 𝑟 , 𝑡 𝑏 = |𝑇 𝑟 ∪ 𝑇 𝑏 | Pablo Estefó - paestefo@dcc.uchile.cl