SlideShare a Scribd company logo
1 of 48
Download to read offline
On the Diffusion ofTest Smells in Automatically
GeneratedTest Code:An Empirical Study
Fabio Palomba*, Dario Di Nucci*,Annibale Panichella+,
Rocco Oliveto°,Andrea De Lucia*
* University of Salerno, Italy
+Delft University ofTechnology,The Netherlands
° University of Molise, Italy
SBST 2016
May, 16th 2016
Austin,TX, USA
Automatic Generation ofTest Code
method1()
method2()
…
methodN()
Production Class
test_method1()
test_method2()
…
test_methodN()
Test Suite
Automatic Generation ofTest Code
[Arcuri and Fraser - SSBSE’14]
Effectiveness of Whole Suite
Test Case Generation
[Panichella et al. - ICSE’16]
Impact ofTest Case Summaries
on Bug Fixing Performance
[Shamshiri et al. - ASE’15]
Effectiveness of Generated
Test Cases on Effectiveness
Automatic Generation ofTest Code
[Rojas et al. - ISSTA’15]
Usability of Automatic
GenerationTools in Practice
Automatic Generation ofTest Code
What about the characteristics of test code produced by such tools?
Test Smells inTest Code
[Van Deursen et al. - XP 2001]
“Test Smells represent a set of a
poor design solutions to write tests ”
11test smells related to the way
developers write test fixtures
and test cases
Test Smells inTest Code
public void test12 () throws Throwable {
JSTerm jSTerm0 = new JSTerm();

jSTerm0.makeVariable () ;
jSTerm0.add((Object) ””);
jSTerm0.matches(jSTerm0);

assertEquals (false, jSTerm0.isGround ());
assertEquals(true, jSTerm0.isVariable());
}
Test Smells inTest Code
public void test12 () throws Throwable {
JSTerm jSTerm0 = new JSTerm();

jSTerm0.makeVariable () ;
jSTerm0.add((Object) ””);
jSTerm0.matches(jSTerm0);

assertEquals (false, jSTerm0.isGround ());
assertEquals(true, jSTerm0.isVariable());
}
The test method checks the production method isGround()
Test Smells inTest Code
public void test12 () throws Throwable {
JSTerm jSTerm0 = new JSTerm();

jSTerm0.makeVariable () ;
jSTerm0.add((Object) ””);
jSTerm0.matches(jSTerm0);

assertEquals (false, jSTerm0.isGround ());
assertEquals(true, jSTerm0.isVariable());
}
But also the production method isVariable()
Test Smells inTest Code
public void test12 () throws Throwable {
JSTerm jSTerm0 = new JSTerm();

jSTerm0.makeVariable () ;
jSTerm0.add((Object) ””);
jSTerm0.matches(jSTerm0);

assertEquals (false, jSTerm0.isGround ());
assertEquals(true, jSTerm0.isVariable());
}
This is an EagerTest, namely a test which checks more than
one method of the class to be tested, making difficult
the comprehension of the actual test target.
Test Smells inTest Code
A test case is affected by a Resource Optimism when
it makes assumptions about the state or the existence
of external resources, providing a non-deterministic
result that depend on the state of the resources.
An Assertion Roulette comes from having a number of
assertions in a test method that have no explanation.
If an assertion fails, the identification of
the assert that failed can be difficult.
Who cares aboutTest Smells?
Test Cases can be re-generated!
Who cares aboutTest Smells?
Test Cases can be re-generated!
True
Who cares aboutTest Smells?
Test Cases can be re-generated!
True
BUT
Who cares aboutTest Smells?
Test Cases can be re-generated!
Developers modify and remove test code
Developers add tests when automatic tools leave
uncovered branches
Developers combine generated with manually written tests
[Rojas et al. - ISSTA’15]
Usability of Automatic GenerationTools in Practice
True
BUT
On the Diffusion ofTest Smells in Automatically
GeneratedTest Code:An Empirical Study
Empirical Study Design
Empirical Study Design
8test smell types
“RefactoringTest Code”
[Van Deursen et al. - XP 2001]
Empirical Study Design
110software projects
8test smell types
[Fraser and Arcuri -TOSEM 2014]
“A Large Scale Evaluation of Automated Unit
Test Generation using Evosuite”
“RefactoringTest Code”
[Van Deursen et al. - XP 2001]
Empirical Study Design
110software projects
8test smell types
[Fraser and Arcuri -TOSEM 2014]
“A Large Scale Evaluation of Automated Unit
Test Generation using Evosuite”
“RefactoringTest Code”
[Van Deursen et al. - XP 2001]
Empirical Study Design
16,603JUnit classes
[Fraser and Arcuri -TOSEM 2014]
“A Large Scale Evaluation of Automated Unit
Test Generation using Evosuite”
Data Extraction
test_method1()
test_method2()
…
test_methodN()
Test Suite
[Bavota et al. - EMSE 2015]
“AreTest Smells Harmful? An Empirical Study”
Test Smell Detector
Data Extraction
test_method1()
test_method2()
…
test_methodN()
Test Suite
[Bavota et al. - EMSE 2015]
“AreTest Smells Harmful? An Empirical Study”
Test Smell Detector
75%
precision
100%
recall
Sample size: 378 JUnit classes
Research Questions
RQ1:To What ExtentTest Smells are Spread in
Automatically GeneratedTest Classes?
?
RQ1:To What ExtentTest Smells are Spread in
Automatically GeneratedTest Classes?
RQ2:WhichTest Smells Occur More Frequently
in Automatically GeneratedTest Classes?
?
Research Questions
RQ1:To What ExtentTest Smells are Spread in
Automatically GeneratedTest Classes?
RQ2:WhichTest Smells Occur More Frequently
in Automatically GeneratedTest Classes?
RQ3:WhichTest Smells Co-OccurTogether?
?
Research Questions
RQ1:To What ExtentTest Smells are Spread in
Automatically GeneratedTest Classes?
RQ2:WhichTest Smells Occur More Frequently
in Automatically GeneratedTest Classes?
RQ3:WhichTest Smells Co-OccurTogether?
RQ4: IsThere a Relationship Between the Presence
ofTest Smells and the Project Characteristics?
?
Research Questions
On the Diffusion ofTest Smells in Automatically
GeneratedTest Code:An Empirical Study
Analysis of the Results
Results of the Study
RQ1:To What ExtentTest Smells are Spread in
Automatically GeneratedTest Classes?
!13,791smelly JUnit classes
Results of the Study
RQ1:To What ExtentTest Smells are Spread in
Automatically GeneratedTest Classes?
!83%of the JUnit classes analyzed
Results of the Study
RQ1:To What ExtentTest Smells are Spread in
Automatically GeneratedTest Classes?
!RQ1
Test Smells are highly diffused in the
automatically generated test suites
RQ2:WhichTest Smells Occur More Frequently
in Automatically GeneratedTest Classes?
Results of the Study
!Assertion Roulette 54%
RQ2:WhichTest Smells Occur More Frequently
in Automatically GeneratedTest Classes?
Results of the Study
!Assertion Roulette 54%
Test Code Duplication
33%
RQ2:WhichTest Smells Occur More Frequently
in Automatically GeneratedTest Classes?
Results of the Study
!Assertion Roulette 54%
Test Code Duplication
EagerTest
33%
29%
RQ2:WhichTest Smells Occur More Frequently
in Automatically GeneratedTest Classes?
Results of the Study
!public void test8 () throws Throwable {
Document document0 = new Document();

assertNotNull(document0);
document0.procText.add((Character) ”s”);
String string0 = document0.stringify();

assertEquals (“s”, document0.stringify()); 

assertNotNull(string0);

assertEquals(“s”, string0);
}
Assertion Roulette
RQ2:WhichTest Smells Occur More Frequently
in Automatically GeneratedTest Classes?
Results of the Study
!
Assertion Roulette
What is the behavior
under test?
Are the generated
assertions valid?
RQ2:WhichTest Smells Occur More Frequently
in Automatically GeneratedTest Classes?
Results of the Study
!
Assertion Roulette
[Panichella et al. - ICSE’16]
The Impact ofTest Case Summaries on Bug Fixing Performance
An Empirical Investigation
These problems have a huge impact on
developers’ ability to find faults
RQ2:WhichTest Smells Occur More Frequently
in Automatically GeneratedTest Classes?
Results of the Study
!public void test8 () throws Throwable {
GenericProperties generic0 = new GenericProperties();

boolean boolean0 = generic0.isValidClassname();
…
}
Test Code Duplication
public void test9 () throws Throwable {
GenericProperties generic0 = new GenericProperties();

boolean boolean0 = generic0.isValidClassname();
…
}
RQ2:WhichTest Smells Occur More Frequently
in Automatically GeneratedTest Classes?
Results of the Study
!
Test Code Duplication
This problem can be avoided by
generating test fixtures!
Results of the Study
!
RQ3:WhichTest Smells Co-OccurTogether?
Assertion Roulette Eager Test
Assertion Roulette Sensitive Equality
Resource Optimism Mystery Guest
Results of the Study
!
RQ3:WhichTest Smells Co-OccurTogether?
Assertion Roulette Eager Test
Assertion Roulette Sensitive Equality
Resource Optimism Mystery Guest
Automatic tools have as main goal that of maximize
coverage, without considering test code quality
RQ4: IsThere a Relationship Between the Presence
ofTest Smells and the Project Characteristics?
Results of the Study
!Yes! The higher the LOC to be tested, the higher the
probability to produce a smelly test case!
RQ4: IsThere a Relationship Between the Presence
ofTest Smells and the Project Characteristics?
Results of the Study
!Yes! The higher the LOC to be tested, the higher the
probability to produce a smelly test case!
The higher the LOC of the JUnit class, the higher the
probability to produce a smelly test case!
Summarizing
Lesson 1: Current implementations of search-based algorithms
for automatic test case generation do not consider code quality,
increasing the probability to introduce smells!
Summarizing
Lesson 1: Current implementations of search-based algorithms
for automatic test case generation do not consider code quality,
increasing the probability to introduce smells!
NB: Considering test code quality is important not only to
avoid the introduction of smells, but also because the
coverage can be increased!
[F. Palomba,A. Panichella,A. Zaidman, R. Oliveto,A. De Lucia - ISSTA’16]
AutomaticTest Case Generation:What IfTest Code Quality Matters?
Summarizing
Lesson 2:Automatic test case generation tools do not produce
text fixtures during their computation, and this implies the
introduction of several code clones in the resulting JUnit classes.
Future research should spend effort in the automatic
generation of test fixtures!
From now on…
?
Challenge 1: EvaluatingTest Smells inTest Cases
automatically generated by other tools
From now on…
?
Challenge 1: EvaluatingTest Smells inTest Cases
automatically generated by other tools
Challenge 2: Defining new algorithms able to solve
the design problems analyzed (e.g., test fixtures).
On the Diffusion ofTest Smells in Automatically
GeneratedTest Code:An Empirical Study
Fabio Palomba*, Dario Di Nucci*,Annibale Panichella+,
Rocco Oliveto°,Andrea De Lucia*
* University of Salerno, Italy
+Delft University ofTechnology,The Netherlands
° University of Molise, Italy
SBST 2016
May, 16th 2016
Austin,TX, USA

More Related Content

What's hot

Revisiting Code Ownership and Its Relationship with Software Quality in the S...
Revisiting Code Ownership and Its Relationship with Software Quality in the S...Revisiting Code Ownership and Its Relationship with Software Quality in the S...
Revisiting Code Ownership and Its Relationship with Software Quality in the S...
The University of Adelaide
 
Investigating Code Review Practices in Defective Files
Investigating Code Review Practices in Defective FilesInvestigating Code Review Practices in Defective Files
Investigating Code Review Practices in Defective Files
The University of Adelaide
 
A Multidimensional Empirical Study on Refactoring Activity
A Multidimensional Empirical Study on Refactoring ActivityA Multidimensional Empirical Study on Refactoring Activity
A Multidimensional Empirical Study on Refactoring Activity
Nikolaos Tsantalis
 
MAVIS: A Visualization Tool for Cohesion-based Bad Smell Inspection
MAVIS: A Visualization Tool for Cohesion-based Bad Smell InspectionMAVIS: A Visualization Tool for Cohesion-based Bad Smell Inspection
MAVIS: A Visualization Tool for Cohesion-based Bad Smell Inspection
立偉 馬
 

What's hot (12)

Social Debt Analytics for Improving the Management of Software Evolution Tasks
Social Debt Analytics for Improving the Management of Software Evolution TasksSocial Debt Analytics for Improving the Management of Software Evolution Tasks
Social Debt Analytics for Improving the Management of Software Evolution Tasks
 
Who Should Review My Code?
Who Should Review My Code?  Who Should Review My Code?
Who Should Review My Code?
 
Msr17a.ppt
Msr17a.pptMsr17a.ppt
Msr17a.ppt
 
Revisiting Code Ownership and Its Relationship with Software Quality in the S...
Revisiting Code Ownership and Its Relationship with Software Quality in the S...Revisiting Code Ownership and Its Relationship with Software Quality in the S...
Revisiting Code Ownership and Its Relationship with Software Quality in the S...
 
Improving Code Review Effectiveness Through Reviewer Recommendations
Improving Code Review Effectiveness Through Reviewer RecommendationsImproving Code Review Effectiveness Through Reviewer Recommendations
Improving Code Review Effectiveness Through Reviewer Recommendations
 
Investigating Code Review Practices in Defective Files
Investigating Code Review Practices in Defective FilesInvestigating Code Review Practices in Defective Files
Investigating Code Review Practices in Defective Files
 
Ph.D. Thesis Defense: Studying Reviewer Selection and Involvement in Modern ...
Ph.D. Thesis Defense:  Studying Reviewer Selection and Involvement in Modern ...Ph.D. Thesis Defense:  Studying Reviewer Selection and Involvement in Modern ...
Ph.D. Thesis Defense: Studying Reviewer Selection and Involvement in Modern ...
 
A Method to Detect License Inconsistencies for Large-Scale Open Source Projects
A Method to Detect License Inconsistencies for Large-Scale Open Source ProjectsA Method to Detect License Inconsistencies for Large-Scale Open Source Projects
A Method to Detect License Inconsistencies for Large-Scale Open Source Projects
 
2011 08 21 - LOINC Tutorial and Mapping Bootcamp - PHI 2011 Conference
2011 08 21 - LOINC Tutorial and Mapping Bootcamp - PHI 2011 Conference2011 08 21 - LOINC Tutorial and Mapping Bootcamp - PHI 2011 Conference
2011 08 21 - LOINC Tutorial and Mapping Bootcamp - PHI 2011 Conference
 
A Multidimensional Empirical Study on Refactoring Activity
A Multidimensional Empirical Study on Refactoring ActivityA Multidimensional Empirical Study on Refactoring Activity
A Multidimensional Empirical Study on Refactoring Activity
 
MAVIS: A Visualization Tool for Cohesion-based Bad Smell Inspection
MAVIS: A Visualization Tool for Cohesion-based Bad Smell InspectionMAVIS: A Visualization Tool for Cohesion-based Bad Smell Inspection
MAVIS: A Visualization Tool for Cohesion-based Bad Smell Inspection
 
Quantifying the Value of Static Analysis
Quantifying the Value of Static AnalysisQuantifying the Value of Static Analysis
Quantifying the Value of Static Analysis
 

Viewers also liked

Scenario Testing
Scenario TestingScenario Testing
Scenario Testing
realbot
 
Hallgrímur pétursson
Hallgrímur péturssonHallgrímur pétursson
Hallgrímur pétursson
tinnamj2190
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practices
nickokiss
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPT
suhasreddy1
 

Viewers also liked (17)

EclipseCon: Test Confessions - What Eclipsers think and do about testing
EclipseCon: Test Confessions - What Eclipsers think and do about testingEclipseCon: Test Confessions - What Eclipsers think and do about testing
EclipseCon: Test Confessions - What Eclipsers think and do about testing
 
Scenario Testing
Scenario TestingScenario Testing
Scenario Testing
 
Anatomy of Test Driven Development
Anatomy of Test Driven DevelopmentAnatomy of Test Driven Development
Anatomy of Test Driven Development
 
तुम बिन जाएँ कहाँ
तुम बिन जाएँ कहाँतुम बिन जाएँ कहाँ
तुम बिन जाएँ कहाँ
 
205230 primavera installation walkthrough
205230 primavera installation walkthrough205230 primavera installation walkthrough
205230 primavera installation walkthrough
 
Hallgrímur pétursson
Hallgrímur péturssonHallgrímur pétursson
Hallgrímur pétursson
 
Mahmoud Al Khouli_CV2015
Mahmoud Al Khouli_CV2015Mahmoud Al Khouli_CV2015
Mahmoud Al Khouli_CV2015
 
शायद इसी को
शायद इसी कोशायद इसी को
शायद इसी को
 
Howison CAREER journey - NSF CISE CAREER Workshop 2016
Howison CAREER journey - NSF CISE CAREER Workshop 2016Howison CAREER journey - NSF CISE CAREER Workshop 2016
Howison CAREER journey - NSF CISE CAREER Workshop 2016
 
1310799 권세진
1310799 권세진1310799 권세진
1310799 권세진
 
Apresentação prof luíz senna
Apresentação prof luíz sennaApresentação prof luíz senna
Apresentação prof luíz senna
 
Endocarditis infecciosa
Endocarditis infecciosaEndocarditis infecciosa
Endocarditis infecciosa
 
Extract Package Refactoring in ARIES
Extract Package Refactoring in ARIESExtract Package Refactoring in ARIES
Extract Package Refactoring in ARIES
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practices
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPT
 
10 Challenges for Emerging Market Startup Ecosystems
10 Challenges for Emerging Market Startup Ecosystems10 Challenges for Emerging Market Startup Ecosystems
10 Challenges for Emerging Market Startup Ecosystems
 
la formacion del sistema educativo mexicano
la formacion del sistema educativo mexicanola formacion del sistema educativo mexicano
la formacion del sistema educativo mexicano
 

Similar to On the Diffusion of Test Smells in Automatically Generated Test Code: An Empirical Study

Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
catherinewall
 
Test design techniques
Test design techniquesTest design techniques
Test design techniques
Oksana
 
Make good use of explortary testing
Make good use of explortary testingMake good use of explortary testing
Make good use of explortary testing
gaoliang641
 
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
 

Similar to On the Diffusion of Test Smells in Automatically Generated Test Code: An Empirical Study (20)

Strategies to Avoid Test Fixture Smells durin Software Evolution
Strategies to Avoid Test Fixture Smells durin Software EvolutionStrategies to Avoid Test Fixture Smells durin Software Evolution
Strategies to Avoid Test Fixture Smells durin Software Evolution
 
Revisiting Test Smells in Automatically Generated Tests: Limitations, Pitfall...
Revisiting Test Smells in Automatically Generated Tests: Limitations, Pitfall...Revisiting Test Smells in Automatically Generated Tests: Limitations, Pitfall...
Revisiting Test Smells in Automatically Generated Tests: Limitations, Pitfall...
 
Does Refactoring of Test Smells Induce Fixing Flaky Tests?
Does Refactoring of Test Smells Induce Fixing Flaky Tests?Does Refactoring of Test Smells Induce Fixing Flaky Tests?
Does Refactoring of Test Smells Induce Fixing Flaky Tests?
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)
 
Test design techniques
Test design techniquesTest design techniques
Test design techniques
 
Make good use of explortary testing
Make good use of explortary testingMake good use of explortary testing
Make good use of explortary testing
 
Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...
Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...
Pairwise Software Test Design - What exactly is pairwise coverage? What is 3-...
 
Software testing foundation
Software testing foundationSoftware testing foundation
Software testing foundation
 
Thinking in software testing
Thinking in software testingThinking in software testing
Thinking in software testing
 
2-Way Coverage vs 3-Way Coverage
2-Way Coverage vs 3-Way Coverage2-Way Coverage vs 3-Way Coverage
2-Way Coverage vs 3-Way Coverage
 
ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1ISTQB / ISEB Foundation Exam Practice -1
ISTQB / ISEB Foundation Exam Practice -1
 
Java Unit Testing
Java Unit TestingJava Unit Testing
Java Unit Testing
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
 
Testing
TestingTesting
Testing
 
Orthogonal array approach a case study
Orthogonal array approach   a case studyOrthogonal array approach   a case study
Orthogonal array approach a case study
 
Speeding-up Software Testing With Computational Intelligence
Speeding-up Software Testing With Computational IntelligenceSpeeding-up Software Testing With Computational Intelligence
Speeding-up Software Testing With Computational Intelligence
 
ISTQB, ISEB Lecture Notes
ISTQB, ISEB Lecture NotesISTQB, ISEB Lecture Notes
ISTQB, ISEB Lecture Notes
 
Qc trg 16 apr 2020
Qc trg 16 apr 2020Qc trg 16 apr 2020
Qc trg 16 apr 2020
 
Rapid Software Testing: Reporting
Rapid Software Testing: ReportingRapid Software Testing: Reporting
Rapid Software Testing: Reporting
 

More from Fabio Palomba

More from Fabio Palomba (6)

Textual Analysis for Code Smell Detection
Textual Analysis for Code Smell DetectionTextual Analysis for Code Smell Detection
Textual Analysis for Code Smell Detection
 
ARIES: An Eclipse Plug-in To Support Extract Class Refactoring
ARIES: An Eclipse Plug-in To Support Extract Class RefactoringARIES: An Eclipse Plug-in To Support Extract Class Refactoring
ARIES: An Eclipse Plug-in To Support Extract Class Refactoring
 
People management
People managementPeople management
People management
 
Next! - An Android application to support tourists activities
Next! - An Android application to support tourists activitiesNext! - An Android application to support tourists activities
Next! - An Android application to support tourists activities
 
A false digital alibi on Mac OS X
A false digital alibi on Mac OS XA false digital alibi on Mac OS X
A false digital alibi on Mac OS X
 
Un plug-in Eclipse per il supporto all'Extract Class Refactoring
Un plug-in Eclipse per il supporto all'Extract Class RefactoringUn plug-in Eclipse per il supporto all'Extract Class Refactoring
Un plug-in Eclipse per il supporto all'Extract Class Refactoring
 

Recently uploaded

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Recently uploaded (20)

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 

On the Diffusion of Test Smells in Automatically Generated Test Code: An Empirical Study

  • 1. On the Diffusion ofTest Smells in Automatically GeneratedTest Code:An Empirical Study Fabio Palomba*, Dario Di Nucci*,Annibale Panichella+, Rocco Oliveto°,Andrea De Lucia* * University of Salerno, Italy +Delft University ofTechnology,The Netherlands ° University of Molise, Italy SBST 2016 May, 16th 2016 Austin,TX, USA
  • 2. Automatic Generation ofTest Code method1() method2() … methodN() Production Class test_method1() test_method2() … test_methodN() Test Suite
  • 3. Automatic Generation ofTest Code [Arcuri and Fraser - SSBSE’14] Effectiveness of Whole Suite Test Case Generation [Panichella et al. - ICSE’16] Impact ofTest Case Summaries on Bug Fixing Performance [Shamshiri et al. - ASE’15] Effectiveness of Generated Test Cases on Effectiveness
  • 4. Automatic Generation ofTest Code [Rojas et al. - ISSTA’15] Usability of Automatic GenerationTools in Practice
  • 5. Automatic Generation ofTest Code What about the characteristics of test code produced by such tools?
  • 6. Test Smells inTest Code [Van Deursen et al. - XP 2001] “Test Smells represent a set of a poor design solutions to write tests ” 11test smells related to the way developers write test fixtures and test cases
  • 7. Test Smells inTest Code public void test12 () throws Throwable { JSTerm jSTerm0 = new JSTerm();
 jSTerm0.makeVariable () ; jSTerm0.add((Object) ””); jSTerm0.matches(jSTerm0);
 assertEquals (false, jSTerm0.isGround ()); assertEquals(true, jSTerm0.isVariable()); }
  • 8. Test Smells inTest Code public void test12 () throws Throwable { JSTerm jSTerm0 = new JSTerm();
 jSTerm0.makeVariable () ; jSTerm0.add((Object) ””); jSTerm0.matches(jSTerm0);
 assertEquals (false, jSTerm0.isGround ()); assertEquals(true, jSTerm0.isVariable()); } The test method checks the production method isGround()
  • 9. Test Smells inTest Code public void test12 () throws Throwable { JSTerm jSTerm0 = new JSTerm();
 jSTerm0.makeVariable () ; jSTerm0.add((Object) ””); jSTerm0.matches(jSTerm0);
 assertEquals (false, jSTerm0.isGround ()); assertEquals(true, jSTerm0.isVariable()); } But also the production method isVariable()
  • 10. Test Smells inTest Code public void test12 () throws Throwable { JSTerm jSTerm0 = new JSTerm();
 jSTerm0.makeVariable () ; jSTerm0.add((Object) ””); jSTerm0.matches(jSTerm0);
 assertEquals (false, jSTerm0.isGround ()); assertEquals(true, jSTerm0.isVariable()); } This is an EagerTest, namely a test which checks more than one method of the class to be tested, making difficult the comprehension of the actual test target.
  • 11. Test Smells inTest Code A test case is affected by a Resource Optimism when it makes assumptions about the state or the existence of external resources, providing a non-deterministic result that depend on the state of the resources. An Assertion Roulette comes from having a number of assertions in a test method that have no explanation. If an assertion fails, the identification of the assert that failed can be difficult.
  • 12. Who cares aboutTest Smells? Test Cases can be re-generated!
  • 13. Who cares aboutTest Smells? Test Cases can be re-generated! True
  • 14. Who cares aboutTest Smells? Test Cases can be re-generated! True BUT
  • 15. Who cares aboutTest Smells? Test Cases can be re-generated! Developers modify and remove test code Developers add tests when automatic tools leave uncovered branches Developers combine generated with manually written tests [Rojas et al. - ISSTA’15] Usability of Automatic GenerationTools in Practice True BUT
  • 16. On the Diffusion ofTest Smells in Automatically GeneratedTest Code:An Empirical Study Empirical Study Design
  • 17. Empirical Study Design 8test smell types “RefactoringTest Code” [Van Deursen et al. - XP 2001]
  • 18. Empirical Study Design 110software projects 8test smell types [Fraser and Arcuri -TOSEM 2014] “A Large Scale Evaluation of Automated Unit Test Generation using Evosuite” “RefactoringTest Code” [Van Deursen et al. - XP 2001]
  • 19. Empirical Study Design 110software projects 8test smell types [Fraser and Arcuri -TOSEM 2014] “A Large Scale Evaluation of Automated Unit Test Generation using Evosuite” “RefactoringTest Code” [Van Deursen et al. - XP 2001]
  • 20. Empirical Study Design 16,603JUnit classes [Fraser and Arcuri -TOSEM 2014] “A Large Scale Evaluation of Automated Unit Test Generation using Evosuite”
  • 21. Data Extraction test_method1() test_method2() … test_methodN() Test Suite [Bavota et al. - EMSE 2015] “AreTest Smells Harmful? An Empirical Study” Test Smell Detector
  • 22. Data Extraction test_method1() test_method2() … test_methodN() Test Suite [Bavota et al. - EMSE 2015] “AreTest Smells Harmful? An Empirical Study” Test Smell Detector 75% precision 100% recall Sample size: 378 JUnit classes
  • 23. Research Questions RQ1:To What ExtentTest Smells are Spread in Automatically GeneratedTest Classes? ?
  • 24. RQ1:To What ExtentTest Smells are Spread in Automatically GeneratedTest Classes? RQ2:WhichTest Smells Occur More Frequently in Automatically GeneratedTest Classes? ? Research Questions
  • 25. RQ1:To What ExtentTest Smells are Spread in Automatically GeneratedTest Classes? RQ2:WhichTest Smells Occur More Frequently in Automatically GeneratedTest Classes? RQ3:WhichTest Smells Co-OccurTogether? ? Research Questions
  • 26. RQ1:To What ExtentTest Smells are Spread in Automatically GeneratedTest Classes? RQ2:WhichTest Smells Occur More Frequently in Automatically GeneratedTest Classes? RQ3:WhichTest Smells Co-OccurTogether? RQ4: IsThere a Relationship Between the Presence ofTest Smells and the Project Characteristics? ? Research Questions
  • 27. On the Diffusion ofTest Smells in Automatically GeneratedTest Code:An Empirical Study Analysis of the Results
  • 28. Results of the Study RQ1:To What ExtentTest Smells are Spread in Automatically GeneratedTest Classes? !13,791smelly JUnit classes
  • 29. Results of the Study RQ1:To What ExtentTest Smells are Spread in Automatically GeneratedTest Classes? !83%of the JUnit classes analyzed
  • 30. Results of the Study RQ1:To What ExtentTest Smells are Spread in Automatically GeneratedTest Classes? !RQ1 Test Smells are highly diffused in the automatically generated test suites
  • 31. RQ2:WhichTest Smells Occur More Frequently in Automatically GeneratedTest Classes? Results of the Study !Assertion Roulette 54%
  • 32. RQ2:WhichTest Smells Occur More Frequently in Automatically GeneratedTest Classes? Results of the Study !Assertion Roulette 54% Test Code Duplication 33%
  • 33. RQ2:WhichTest Smells Occur More Frequently in Automatically GeneratedTest Classes? Results of the Study !Assertion Roulette 54% Test Code Duplication EagerTest 33% 29%
  • 34. RQ2:WhichTest Smells Occur More Frequently in Automatically GeneratedTest Classes? Results of the Study !public void test8 () throws Throwable { Document document0 = new Document();
 assertNotNull(document0); document0.procText.add((Character) ”s”); String string0 = document0.stringify();
 assertEquals (“s”, document0.stringify()); 
 assertNotNull(string0);
 assertEquals(“s”, string0); } Assertion Roulette
  • 35. RQ2:WhichTest Smells Occur More Frequently in Automatically GeneratedTest Classes? Results of the Study ! Assertion Roulette What is the behavior under test? Are the generated assertions valid?
  • 36. RQ2:WhichTest Smells Occur More Frequently in Automatically GeneratedTest Classes? Results of the Study ! Assertion Roulette [Panichella et al. - ICSE’16] The Impact ofTest Case Summaries on Bug Fixing Performance An Empirical Investigation These problems have a huge impact on developers’ ability to find faults
  • 37. RQ2:WhichTest Smells Occur More Frequently in Automatically GeneratedTest Classes? Results of the Study !public void test8 () throws Throwable { GenericProperties generic0 = new GenericProperties();
 boolean boolean0 = generic0.isValidClassname(); … } Test Code Duplication public void test9 () throws Throwable { GenericProperties generic0 = new GenericProperties();
 boolean boolean0 = generic0.isValidClassname(); … }
  • 38. RQ2:WhichTest Smells Occur More Frequently in Automatically GeneratedTest Classes? Results of the Study ! Test Code Duplication This problem can be avoided by generating test fixtures!
  • 39. Results of the Study ! RQ3:WhichTest Smells Co-OccurTogether? Assertion Roulette Eager Test Assertion Roulette Sensitive Equality Resource Optimism Mystery Guest
  • 40. Results of the Study ! RQ3:WhichTest Smells Co-OccurTogether? Assertion Roulette Eager Test Assertion Roulette Sensitive Equality Resource Optimism Mystery Guest Automatic tools have as main goal that of maximize coverage, without considering test code quality
  • 41. RQ4: IsThere a Relationship Between the Presence ofTest Smells and the Project Characteristics? Results of the Study !Yes! The higher the LOC to be tested, the higher the probability to produce a smelly test case!
  • 42. RQ4: IsThere a Relationship Between the Presence ofTest Smells and the Project Characteristics? Results of the Study !Yes! The higher the LOC to be tested, the higher the probability to produce a smelly test case! The higher the LOC of the JUnit class, the higher the probability to produce a smelly test case!
  • 43. Summarizing Lesson 1: Current implementations of search-based algorithms for automatic test case generation do not consider code quality, increasing the probability to introduce smells!
  • 44. Summarizing Lesson 1: Current implementations of search-based algorithms for automatic test case generation do not consider code quality, increasing the probability to introduce smells! NB: Considering test code quality is important not only to avoid the introduction of smells, but also because the coverage can be increased! [F. Palomba,A. Panichella,A. Zaidman, R. Oliveto,A. De Lucia - ISSTA’16] AutomaticTest Case Generation:What IfTest Code Quality Matters?
  • 45. Summarizing Lesson 2:Automatic test case generation tools do not produce text fixtures during their computation, and this implies the introduction of several code clones in the resulting JUnit classes. Future research should spend effort in the automatic generation of test fixtures!
  • 46. From now on… ? Challenge 1: EvaluatingTest Smells inTest Cases automatically generated by other tools
  • 47. From now on… ? Challenge 1: EvaluatingTest Smells inTest Cases automatically generated by other tools Challenge 2: Defining new algorithms able to solve the design problems analyzed (e.g., test fixtures).
  • 48. On the Diffusion ofTest Smells in Automatically GeneratedTest Code:An Empirical Study Fabio Palomba*, Dario Di Nucci*,Annibale Panichella+, Rocco Oliveto°,Andrea De Lucia* * University of Salerno, Italy +Delft University ofTechnology,The Netherlands ° University of Molise, Italy SBST 2016 May, 16th 2016 Austin,TX, USA