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@
 
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)

Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
+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...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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 Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

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