SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
Strategies for Avoiding Test
Fixture Smells during
Software Evolution
Michaela Greiler, Andy Zaidman, Arie van Deursen,
Margaret-Anne Storey
Test Fixture Smells
2
What is a test smell?
A symptom of a problem
• Can originate from several causes
• Refactoring needed
3
Structure of a Test
4
Test (method)
Test Structure
1. Statement
2. Statement
3. Statement
4. Statement
5. Statement
6. Statement
Setup of Test Fixture
Verify Outcome
Exercise SUT
Teardown Test Fixture
5
Test Fixture
The code that initializes and configures the system under test
6
How to structure the test fixture
and where to place it?
Test – Inline Fixture
Setup within method
Test Fixture
8
Test – Implicit
Setup
Method
9
Test – Delegate
Method
createTestAirportOriginTest ()
createTestAirportOriginTest(); explicit invocation
deleteTestAirportOriginTest()
deleteTestAirportOriginTest();
}
10
Delegate
“Most of the complexity of writing tests involves
how to write the Test Methods; what to include
inline and what to factor out into Test Utility
Methods, and so on.”
(Meszaros)
11
Test Fixture Smells
• General Fixture
• Test Maverick
• Dead Fields
• Lack of Cohesion of Test Methods
• Vague Header
• Obscure In-line setup
ICST 2013: Greiler, van Deursen, Storey
Automatic Detection of Test Fixture
Strategies and Smells
12
Developers recognize test fixture smells as a
problem(ICST’13)
13
Developers recognize test fixture smells as a
problem(ICST’13)
Resolving these smells after a long time can be problematic.
Immediately awareness of smells density important.
14
1. Investigate the evolution of test fixture smells and
2. Understand which software changes lead to increased test smell densities
to develop strategies to avoid fixture smells and
to determine the best time to alert developers.
15
Resolving these smells after a long time can be problematic.
Immediately awareness of smells density important.
Azure
39 KLOCs
30 T-classes
358 T-methods
300 revisions
1 year
JSoup
20 KLOCs
23 T-classes
372 T-methods
973 revisions
2.5 years
Checkstyle
66 KLOCs
156 T-classes
549 T-methods
2251 revisions
9.5 years
PMD
174 KLOCs
118 T-classes
739 T-methods
1900 revisions
5 years
Voldemort
130 KLOCs
132 T-classes
520 T-methods
2900 revisions
1.5 years
Case studies
16
TestEvoHound
…is a static analysis tool that analyzes the test
fixture smell evolution.
TestEvoHound
…is a static analysis tool that analyzes the test
fixture smell evolution.
1.Revision Checkout
2.Build Process
3.Test Fixture Smell Analysis
4.Trend Analysis
Fixture smells among projects
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%
Azure Checkstyle JSoup PMD Voldemort
Test Mavericks General Fixture Vague Header Dead Fields LCOTM Inline
19
Does Test Fixture Smell Density Increase?
A general growth of test fixture smells over time
does not occur.
20
Lehman’s law: when a system evolves, its complexity increases unless work is
done to maintain or reduce it.
Increase in smell density
Checkstyle: dead fields
Refactoring and forgotten functionality: “Added a helper method to create a
configuration for a check...”.
21
Decrease in smell density
Azure: general fixture
New, non-smelly tests added: “Table Client commit [...]”.
22
Smell Dispersion
Over time, smelly
classes get smellier
Smells cluster in a few
classes
23
Correlations
?
Number of t-methods per test class correlates with test fixture smell density
Number of fields do not necessarily correlate with smell density
# T-methods
# Fields
24
Strategies and Recommendations
Keep test classes small
Keep inheritance structures flat
Limit the scope of super classes
Use composition instead of inheritance
Reconsider the “one test class per class” organization
25
Findings
0%
20%
40%
60%
80%
100%
Azure Checkstyle JSoup PMD VoldemortTest Mavericks General Fixture Vague Header
Dead Fields LCOTM Inline
# T-methods# Fields
26
0%
20%
40%
60%
80%
100%
Azure Checkstyle JSoup PMD VoldemortTest Mavericks General Fixture Vague Header
Dead Fields LCOTM Inline
# T-methods# Fields
Thanks! Questions?
Connect with me
Michaela Greiler
michaela.greiler@microsoft.com
mgreiler
27

Contenu connexe

Tendances

Exploratory Testing
Exploratory TestingExploratory Testing
Exploratory Testing
nazeer pasha
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
catherinewall
 
ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1
Yogindernath Gupta
 
'Continuous Quality Improvements – A Journey Through The Largest Scrum Projec...
'Continuous Quality Improvements – A Journey Through The Largest Scrum Projec...'Continuous Quality Improvements – A Journey Through The Largest Scrum Projec...
'Continuous Quality Improvements – A Journey Through The Largest Scrum Projec...
TEST Huddle
 
want to contact me login to www.stqa.org
want to contact me login to www.stqa.orgwant to contact me login to www.stqa.org
want to contact me login to www.stqa.org
nazeer pasha
 

Tendances (19)

Erik Boelen - Testing, The Next Level
Erik Boelen - Testing, The Next LevelErik Boelen - Testing, The Next Level
Erik Boelen - Testing, The Next Level
 
Unit testing & TDD concepts with best practice guidelines.
Unit testing & TDD concepts with best practice guidelines.Unit testing & TDD concepts with best practice guidelines.
Unit testing & TDD concepts with best practice guidelines.
 
Exploratory Testing
Exploratory TestingExploratory Testing
Exploratory Testing
 
tem7
tem7tem7
tem7
 
David Parnas - Documentation Based Software Testing - SoftTest Ireland
David Parnas - Documentation Based Software Testing - SoftTest IrelandDavid Parnas - Documentation Based Software Testing - SoftTest Ireland
David Parnas - Documentation Based Software Testing - SoftTest Ireland
 
Software Testing 2/5
Software Testing 2/5Software Testing 2/5
Software Testing 2/5
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
Training program BaffleSol academy of learning
Training program BaffleSol academy of learningTraining program BaffleSol academy of learning
Training program BaffleSol academy of learning
 
ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1
 
On The Relation of Test Smells to Software Code Quality
On The Relation of Test Smells to Software Code QualityOn The Relation of Test Smells to Software Code Quality
On The Relation of Test Smells to Software Code Quality
 
Testing Framework
Testing FrameworkTesting Framework
Testing Framework
 
The Art of Testing Less without Sacrificing Quality @ ICSE 2015
The Art of Testing Less without Sacrificing Quality @ ICSE 2015The Art of Testing Less without Sacrificing Quality @ ICSE 2015
The Art of Testing Less without Sacrificing Quality @ ICSE 2015
 
Fundamentals of testing
Fundamentals of testingFundamentals of testing
Fundamentals of testing
 
Introduction to ISTQB & ISEB Certifications
Introduction to ISTQB & ISEB CertificationsIntroduction to ISTQB & ISEB Certifications
Introduction to ISTQB & ISEB Certifications
 
'Continuous Quality Improvements – A Journey Through The Largest Scrum Projec...
'Continuous Quality Improvements – A Journey Through The Largest Scrum Projec...'Continuous Quality Improvements – A Journey Through The Largest Scrum Projec...
'Continuous Quality Improvements – A Journey Through The Largest Scrum Projec...
 
Ôn tập kiến thức ISTQB
Ôn tập kiến thức ISTQBÔn tập kiến thức ISTQB
Ôn tập kiến thức ISTQB
 
ISTQB, ISEB Lecture Notes- 4
ISTQB, ISEB Lecture Notes- 4ISTQB, ISEB Lecture Notes- 4
ISTQB, ISEB Lecture Notes- 4
 
Functional testing
Functional testingFunctional testing
Functional testing
 
want to contact me login to www.stqa.org
want to contact me login to www.stqa.orgwant to contact me login to www.stqa.org
want to contact me login to www.stqa.org
 

Similaire à Strategies to Avoid Test Fixture Smells durin Software Evolution

Ranking Refactoring Suggestions based on Historical Volatility
Ranking Refactoring Suggestions based on Historical VolatilityRanking Refactoring Suggestions based on Historical Volatility
Ranking Refactoring Suggestions based on Historical Volatility
Nikolaos Tsantalis
 
ISTQB / ISEB Foundation Exam Practice - 2
ISTQB / ISEB Foundation Exam Practice - 2ISTQB / ISEB Foundation Exam Practice - 2
ISTQB / ISEB Foundation Exam Practice - 2
Yogindernath Gupta
 

Similaire à Strategies to Avoid Test Fixture Smells durin Software Evolution (20)

On the Diffusion of Test Smells in Automatically Generated Test Code: An Empi...
On the Diffusion of Test Smells in Automatically Generated Test Code: An Empi...On the Diffusion of Test Smells in Automatically Generated Test Code: An Empi...
On the Diffusion of Test Smells in Automatically Generated Test Code: An Empi...
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Combinatorial testing
Combinatorial testingCombinatorial testing
Combinatorial testing
 
testing.pdf
testing.pdftesting.pdf
testing.pdf
 
SE2_Lec 20_Software Testing
SE2_Lec 20_Software TestingSE2_Lec 20_Software Testing
SE2_Lec 20_Software Testing
 
Combinatorial testing ppt
Combinatorial testing pptCombinatorial testing ppt
Combinatorial testing ppt
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
 
Code coverage based test case selection and prioritization
Code coverage based test case selection and prioritizationCode coverage based test case selection and prioritization
Code coverage based test case selection and prioritization
 
Making the Unstable Stable - An Intro To Testing
Making the Unstable Stable - An Intro To TestingMaking the Unstable Stable - An Intro To Testing
Making the Unstable Stable - An Intro To Testing
 
Ranking Refactoring Suggestions based on Historical Volatility
Ranking Refactoring Suggestions based on Historical VolatilityRanking Refactoring Suggestions based on Historical Volatility
Ranking Refactoring Suggestions based on Historical Volatility
 
S440999102
S440999102S440999102
S440999102
 
A Test Analysis Method for Black Box Testing Using AUT and Fault Knowledge.
A Test Analysis Method for Black Box Testing Using AUT and Fault Knowledge.A Test Analysis Method for Black Box Testing Using AUT and Fault Knowledge.
A Test Analysis Method for Black Box Testing Using AUT and Fault Knowledge.
 
SE2018_Lec 19_ Software Testing
SE2018_Lec 19_ Software TestingSE2018_Lec 19_ Software Testing
SE2018_Lec 19_ Software Testing
 
ISTQB / ISEB Foundation Exam Practice - 2
ISTQB / ISEB Foundation Exam Practice - 2ISTQB / ISEB Foundation Exam Practice - 2
ISTQB / ISEB Foundation Exam Practice - 2
 
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
Testing As A Bottleneck - How Testing Slows Down Modern Development Processes...
 
Shift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David LaulusaShift-Left Testing: QA in a DevOps World by David Laulusa
Shift-Left Testing: QA in a DevOps World by David Laulusa
 
Mutation testing
Mutation testingMutation testing
Mutation testing
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Ch23
Ch23Ch23
Ch23
 
Vlsi testing
Vlsi testingVlsi testing
Vlsi testing
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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 - 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...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
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
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Strategies to Avoid Test Fixture Smells durin Software Evolution

  • 1. Strategies for Avoiding Test Fixture Smells during Software Evolution Michaela Greiler, Andy Zaidman, Arie van Deursen, Margaret-Anne Storey
  • 3. What is a test smell? A symptom of a problem • Can originate from several causes • Refactoring needed 3
  • 4. Structure of a Test 4
  • 5. Test (method) Test Structure 1. Statement 2. Statement 3. Statement 4. Statement 5. Statement 6. Statement Setup of Test Fixture Verify Outcome Exercise SUT Teardown Test Fixture 5
  • 6. Test Fixture The code that initializes and configures the system under test 6
  • 7. How to structure the test fixture and where to place it?
  • 8. Test – Inline Fixture Setup within method Test Fixture 8
  • 10. Test – Delegate Method createTestAirportOriginTest () createTestAirportOriginTest(); explicit invocation deleteTestAirportOriginTest() deleteTestAirportOriginTest(); } 10 Delegate
  • 11. “Most of the complexity of writing tests involves how to write the Test Methods; what to include inline and what to factor out into Test Utility Methods, and so on.” (Meszaros) 11
  • 12. Test Fixture Smells • General Fixture • Test Maverick • Dead Fields • Lack of Cohesion of Test Methods • Vague Header • Obscure In-line setup ICST 2013: Greiler, van Deursen, Storey Automatic Detection of Test Fixture Strategies and Smells 12
  • 13. Developers recognize test fixture smells as a problem(ICST’13) 13
  • 14. Developers recognize test fixture smells as a problem(ICST’13) Resolving these smells after a long time can be problematic. Immediately awareness of smells density important. 14
  • 15. 1. Investigate the evolution of test fixture smells and 2. Understand which software changes lead to increased test smell densities to develop strategies to avoid fixture smells and to determine the best time to alert developers. 15 Resolving these smells after a long time can be problematic. Immediately awareness of smells density important.
  • 16. Azure 39 KLOCs 30 T-classes 358 T-methods 300 revisions 1 year JSoup 20 KLOCs 23 T-classes 372 T-methods 973 revisions 2.5 years Checkstyle 66 KLOCs 156 T-classes 549 T-methods 2251 revisions 9.5 years PMD 174 KLOCs 118 T-classes 739 T-methods 1900 revisions 5 years Voldemort 130 KLOCs 132 T-classes 520 T-methods 2900 revisions 1.5 years Case studies 16
  • 17. TestEvoHound …is a static analysis tool that analyzes the test fixture smell evolution.
  • 18. TestEvoHound …is a static analysis tool that analyzes the test fixture smell evolution. 1.Revision Checkout 2.Build Process 3.Test Fixture Smell Analysis 4.Trend Analysis
  • 19. Fixture smells among projects 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% Azure Checkstyle JSoup PMD Voldemort Test Mavericks General Fixture Vague Header Dead Fields LCOTM Inline 19
  • 20. Does Test Fixture Smell Density Increase? A general growth of test fixture smells over time does not occur. 20 Lehman’s law: when a system evolves, its complexity increases unless work is done to maintain or reduce it.
  • 21. Increase in smell density Checkstyle: dead fields Refactoring and forgotten functionality: “Added a helper method to create a configuration for a check...”. 21
  • 22. Decrease in smell density Azure: general fixture New, non-smelly tests added: “Table Client commit [...]”. 22
  • 23. Smell Dispersion Over time, smelly classes get smellier Smells cluster in a few classes 23
  • 24. Correlations ? Number of t-methods per test class correlates with test fixture smell density Number of fields do not necessarily correlate with smell density # T-methods # Fields 24
  • 25. Strategies and Recommendations Keep test classes small Keep inheritance structures flat Limit the scope of super classes Use composition instead of inheritance Reconsider the “one test class per class” organization 25
  • 26. Findings 0% 20% 40% 60% 80% 100% Azure Checkstyle JSoup PMD VoldemortTest Mavericks General Fixture Vague Header Dead Fields LCOTM Inline # T-methods# Fields 26
  • 27. 0% 20% 40% 60% 80% 100% Azure Checkstyle JSoup PMD VoldemortTest Mavericks General Fixture Vague Header Dead Fields LCOTM Inline # T-methods# Fields Thanks! Questions? Connect with me Michaela Greiler michaela.greiler@microsoft.com mgreiler 27