SlideShare a Scribd company logo
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

PDF
PhD Symposium 2014
PDF
A Textual-based Technique for Smell Detection
PDF
When and Why Your Code Starts to Smell Bad
PPTX
Code Smell, Software Engineering
PDF
Do They Really Smell Bad? A Study on Developers' Perception of Bad Code Smells
PDF
Detecting Bad Smells in Source Code using Change History Information
PDF
Smells Like Teen Spirit: Improving Bug Prediction Performance using the Inten...
PDF
Evaluating SZZ Implementations Through a Developer-informed Oracle (ICSE 2021)
PhD Symposium 2014
A Textual-based Technique for Smell Detection
When and Why Your Code Starts to Smell Bad
Code Smell, Software Engineering
Do They Really Smell Bad? A Study on Developers' Perception of Bad Code Smells
Detecting Bad Smells in Source Code using Change History Information
Smells Like Teen Spirit: Improving Bug Prediction Performance using the Inten...
Evaluating SZZ Implementations Through a Developer-informed Oracle (ICSE 2021)

What's hot (12)

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

Viewers also liked (17)

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

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

PDF
Revisiting Test Smells in Automatically Generated Tests: Limitations, Pitfall...
PDF
Test Anti-Patterns: From Definition to Detection
PDF
On the Distribution of Test Smells in Open Source Android Applications: An Ex...
PDF
On The Relation of Test Smells to Software Code Quality
PDF
On the Distribution of "Simple Stupid Bugs" in Unit Test Files: An Explorator...
PDF
Strategies to Avoid Test Fixture Smells durin Software Evolution
PDF
Practices and Tools for Better Software Testing
PDF
PHANTA: Diversified Test Code Quality Measurement for Modern Software Develop...
ODP
Effective unit testing
PDF
VST2022.pdf
PDF
The Joy of Testing - Deep Dive @ Devoxx Belgium 2024
PDF
Better code through making bugs
PPTX
Test Smells Learning by a Gamification Approach
PDF
junit-160729073220 eclipse software testing.pdf
PDF
Completely Test-Driven
PPSX
PDF
Does Refactoring of Test Smells Induce Fixing Flaky Tests?
PDF
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
PPTX
The Test way
PPT
Revisiting Test Smells in Automatically Generated Tests: Limitations, Pitfall...
Test Anti-Patterns: From Definition to Detection
On the Distribution of Test Smells in Open Source Android Applications: An Ex...
On The Relation of Test Smells to Software Code Quality
On the Distribution of "Simple Stupid Bugs" in Unit Test Files: An Explorator...
Strategies to Avoid Test Fixture Smells durin Software Evolution
Practices and Tools for Better Software Testing
PHANTA: Diversified Test Code Quality Measurement for Modern Software Develop...
Effective unit testing
VST2022.pdf
The Joy of Testing - Deep Dive @ Devoxx Belgium 2024
Better code through making bugs
Test Smells Learning by a Gamification Approach
junit-160729073220 eclipse software testing.pdf
Completely Test-Driven
Does Refactoring of Test Smells Induce Fixing Flaky Tests?
AUTOCODECOVERGEN: PROTOTYPE OF DATA DRIVEN UNIT TEST GENRATION TOOL THAT GUAR...
The Test way

More from Fabio Palomba (6)

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

Recently uploaded (20)

PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Nekopoi APK 2025 free lastest update
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Softaken Excel to vCard Converter Software.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
VVF-Customer-Presentation2025-Ver1.9.pptx
wealthsignaloriginal-com-DS-text-... (1).pdf
How to Migrate SBCGlobal Email to Yahoo Easily
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Operating system designcfffgfgggggggvggggggggg
Nekopoi APK 2025 free lastest update
Which alternative to Crystal Reports is best for small or large businesses.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Navsoft: AI-Powered Business Solutions & Custom Software Development
How Creative Agencies Leverage Project Management Software.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool

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