SlideShare a Scribd company logo
On the Distribution of Test
Smells in Open Source
Android Applications: An
Exploratory Study
Anthony Peruma, Khalid Almalki, Christian D. Newman,
Mohamed Wiem Mkaouer, Ali Ouni, Fabio Palomba
29th Annual International Conference on Computer Science and Software Engineering
1.
Introduction
Software maintenance is not cheap!
3
I n t r o d u c t i o n
▸A high-quality system need not be necessarily
maintenance-friendly
▸Systems built using poor design/coding practices
can meet functional requirements
▸In the long run, such events impact software
maintenance - and maintenance is not cheap!
▹ Maintenance consumes 50% to 80% of resources
Towards maintenance-friendly code
4
I n t r o d u c t i o n
▸Researchers and industry have defined and created
approaches and tools to detect code in need of
refactoring
▹ Design/code smells - Cohesion, Coupling, God Class, etc.
▹ Tools - FindBugs, PMD, Checkstyle, etc.
▸Smells make code harder to understand and make it more
prone to bugs and changes
▸Research and tools have been primarily on production code
Test Smells
5
I n t r o d u c t i o n
▸Test code, like production code, is subject to smells
▸Formally introduced in 2001 with 11 smell types
▸Inclusion of additional smell types through the years, analysis
of their evolution and longevity, and elimination patterns
▸Tools to detect specific smell types
▸Studies on traditional Java applications
“2.6 million apps
available on Google Play
as of Q4 2018
Objective
Insight into the unit testing practices of
Android app developers with the aim of
providing developers a mechanism to
improve unit testing code
7
I n t r o d u c t i o n
Contribution
8
I n t r o d u c t i o n & O b j e c t i v e s
Open-Source Test Smell Detection Tool
Understanding of Test Smells in Android apps
Expansion of Test Smell Types
Replication Package Availability
Research Questions
9
I n t r o d u c t i o n
RQ 02
What is the general trend of test smells in Android apps over time?
▹ When are test smells first introduced into the project?
▹ How do test smells exhibited by the apps evolve over time?
RQ 01
How likely are Android apps to contain unit test smells?
▹ Are apps, that contain a test suite, prone to test smells?
▹ What is the frequency and distribution of test smells in apps?
▹ How does the distribution of smell types in Android apps compare against traditional
Java applications?
2.
Test Smells
Proposed Test Smells
11
T e s t S m e l l s
▸ Conditional Test Logic
▸ Constructor Initialization
▸ Default Test
▸ Duplicate Assert
▸ Empty Test
▸ Exception Handling
▸ Ignored Test
▸ Magic Number Test
▸ Redundant Print
▸ Redundant Assertion
▸ Sleepy Test
▸ Unknown Test
Practicability
12
T e s t S m e l l s
120smelly unit
test files
100software
systems
120software
developers
41.7%response
rate
Are our proposed smells indicative of problems?
Conditional Test Logic
13
T e s t S m e l l s
▸ Conditions within the test
method will alter the
behavior of the test and its
expected output
▸ Developers agree on the
negative impact on code
comprehension
▸ However, outright removal
may not always be
applicable – decide on a
“case by case basis”
I actually have no idea why that for loop is there.
It doesn’t do anything but run the test 1000
times, and there’s no point in that. I’ll remove it.
Constructor Initialization
14
T e s t S m e l l s
▸ Initialization of fields should
be in the setUp() method
(i.e., test fixtures)
▸ Most developers are aware
of test fixtures
▸ Developers unanimously
agree on using test fixtures
▸ Reasons for not using test
fixtures include “laziness”
and being “sloppy” I have already made this change since you
pointed it out so the code is clearer now
Default Test
15
T e s t S m e l l s
▸ Default test class meant to
serve as an example
▸ Should either be removed
▸ A test-first approach will
force developers to remove
the file
▸ Unanimous agreement
among developers that the
file “serves no concrete
purpose” and that it may
lead to confusion Removed useless example unit test
Duplicate Assert
16
T e s t S m e l l s
▸ The same condition is
tested multiple times within
the same test method
▸ The name of the test
method should be an
indication of the test
▸ Mixed responses - some
developers preferred to split
the assertion statement into
separate methods
I might enforce it on some bigger projects
Empty Test
17
T e s t S m e l l s
▸ When a test method has no
executable statements
▸ JUnit will indicate that the
test passes even if there are
no executable statements
present in the method body
▸ Unanimous agreement
among developers that such
test methods should be
removed from the test suite
Yes definitely should be removed
Exception Handling
18
T e s t S m e l l s
▸ Passing or failing of a test
method is explicitly
dependent on the production
method throwing an
exception
▸ Developers should utilize
JUnit’s exception handling
features to automatically
pass/fail
Ignored Test
19
T e s t S m e l l s
▸ Ignored test methods result
in overhead with regards to
compilation time and an
increase in code complexity
and comprehension
▸ Mixed responses -
investigate problems or
serve as a means for new
developers “to understand
behavior”
would not tolerate to have ignored tests in the code
Magic Number Test
20
T e s t S m e l l s
▸ Test method contains
unexplained and
undocumented numeric
literals
▸ Developers agree that the
use of constants over magic
numbers improve code
readability/understandability
▸ Not a blanket rule - a
constant should only be
used so that its “name adds
useful information”
If the numerical value has a deeper meaning (e.g.
flag, physical constant, enum value) then a
constant should be used.
Redundant Assertion
21
T e s t S m e l l s
▸ Assertion statements that
are either always true or
false
▸ Common reason for the
existence of this smell is
due to developer mistakes
▸ Developers confirmed that
such code “is not needed”,
“bad style” and “should
probably be removed”
▸ Might exist to support edge
cases
Redundant Print
22
T e s t S m e l l s
▸ Unit tests are executed as
part of an automated script
▸ They can consume
computing resources or
increase execution time
▸ Unanimous agreement that
print statements do not
belong in test suites
▸ A common reason for the
existence of this smell is
due to developer debugging
a waste of resources (cpu+disk space)
Sleepy Test
23
T e s t S m e l l s
▸ Explicitly causing a thread to
sleep can lead to
unexpected results as the
processing time for a task
differs when executed in
various environments and
configurations
▸ Developers confirmed that
there are risks (i.e.,
inconsistent results)
involved with causing a
thread to sleep
the alternative requires more code
Unknown Test
24
T e s t S m e l l s
▸ The assertion statement
helps to indicate the
purpose of the test
▸ JUnit will show the test
method as passing
▸ Majority of the developers
are in favor of having
assertion statements in a
test method
▸ Missing assertions were due
to mistakes
It looks like just sloppy coding there.
I'll look to fix that test
TSDetect
▸ Open-source, Java-based,
static analysis
▸ Available as a standalone
jar and requires a list of file
paths as input
▸ Utilizes an abstract syntax
tree to parse and detect
test smells
▸ Detects 19 test smells (12
proposed + 7 existing)
▸ Average F-Score of 96.5%
25
T e s t S m e l l s
High-level architecture of TSDetect
3.
Experiment Methodology
Data Collection Phase
27
E x p e r i m e n t M e t h o d o l o g y
F-Droid
Repositories
Data Mining
Tools
Mining
Output
2,011cloned apps
1,037,236
commits
6,379,006
java files affected by commits
+3.5 GB
java files collected
Detection Phase
28
E x p e r i m e n t M e t h o d o l o g y
Test File
Detection Tool
Test Smell
Detection Tool
Syntactically correct
test files with 1 or
more test methods
Detected test smells
656analyzed apps
206,598
detected test files
1,187,055
analyzed test methods
175,866
test files with 1 or more smells
4.
Analysis & Discussion
RQ1 – Test Smell Occurrence
Test Smell Occurrence & Distribution
▹ 97% of the analyzed apps contained test smells
▹ Assertion Roulette occurred the most (in over
50% of the analyzed apps and test files)
▹ All smell types had a high co-occurrence with
Assertion Roulette
▹ Similar distribution of test smells between
Android and non-Android applications
30
A n a l y s i s & D i s c u s s i o n
RQ1 – Test Smell Occurrence
31
0.00%
2.00%
4.00%
6.00%
8.00%
10.00%
12.00%
14.00%
16.00%
18.00%
S m e l l T y p e D i s t r i b u t i o n S m e l l T y p e O c c u r r e n c e
A n a l y s i s & D i s c u s s i o n
RQ1 – Test Smell Occurrence
32
A n a l y s i s & D i s c u s s i o n
S m e l l T y p e C o - O c c u r r e n c e
RQ2 – Test Smell Trend
33
A n a l y s i s & D i s c u s s i o n
Test Smell Introduction
▹ The first inclusion of a smelly file occurs
approximately 23% of the way through the total
app commits
▹ A test file is added with 3 smell types
▹ Assertion Roulette is the frequently the first
smell type introduced
▹ Smells exhibited by a file remains constant
throughout all updates to the file
5.
Conclusion
Summary
35
C o n c l u s i o n
▸ Extended the catalog of known
unit test smells
▸ Open source test smell
detection tool
▸ A study of 656 Android apps
showed a high prevalence of
test smells in test suites
▸ Smells are introduced early on
into the codebase and exist
during the lifetime of the app
▸ Comprehensive project website:
https://testsmells.github.io
Thanks!
https://testsmells.github.io

More Related Content

What's hot (20)

PDF
Can we induce change with what we measure?
Michaela Greiler
 
PDF
Strategies to Avoid Test Fixture Smells durin Software Evolution
Michaela Greiler
 
PDF
Exploratory Testing
nazeer pasha
 
PDF
130817 latifa guerrouj - context-aware source code vocabulary normalization...
Ptidej Team
 
PDF
Exploring Exploratory Testing
nazeer pasha
 
PPT
Unit testing
dubbu
 
PDF
[Tho Quan] Fault Localization - Where is the root cause of a bug?
Ho Chi Minh City Software Testing Club
 
PPTX
Software Testing 1/5
Damian T. Gordon
 
PDF
QUALITY METRICS OF TEST SUITES IN TESTDRIVEN DESIGNED APPLICATIONS
ijseajournal
 
PPTX
Basics of software testing
PJS KUMAR
 
PDF
Search-based testing of procedural programs:iterative single-target or multi-...
Vrije Universiteit Brussel
 
PPTX
10 software testing_technique
University of Computer Science and Technology
 
PDF
On the Malware Detection Problem: Challenges & Novel Approaches
Marcus Botacin
 
PPTX
Finding Help with Programming Errors: An Exploratory Study of Novice Software...
Preetha Chatterjee
 
PPTX
Exploratory Study of Slack Q&A Chats as a Mining Source for Software Engineer...
Preetha Chatterjee
 
PPTX
Test-Driven Development
Ny Fanilo Andrianjafy, B.Eng.
 
PDF
Software testing
prasad g
 
PPTX
Predicting Usefulness of Code Review Comments using Textual Features and Deve...
Masud Rahman
 
PPTX
The End-to-End Use of Source Code Example: An Exploratory Study ICSM'09
Rylan Cottrell
 
PDF
Sound Empirical Evidence in Software Testing
Jaguaraci Silva
 
Can we induce change with what we measure?
Michaela Greiler
 
Strategies to Avoid Test Fixture Smells durin Software Evolution
Michaela Greiler
 
Exploratory Testing
nazeer pasha
 
130817 latifa guerrouj - context-aware source code vocabulary normalization...
Ptidej Team
 
Exploring Exploratory Testing
nazeer pasha
 
Unit testing
dubbu
 
[Tho Quan] Fault Localization - Where is the root cause of a bug?
Ho Chi Minh City Software Testing Club
 
Software Testing 1/5
Damian T. Gordon
 
QUALITY METRICS OF TEST SUITES IN TESTDRIVEN DESIGNED APPLICATIONS
ijseajournal
 
Basics of software testing
PJS KUMAR
 
Search-based testing of procedural programs:iterative single-target or multi-...
Vrije Universiteit Brussel
 
10 software testing_technique
University of Computer Science and Technology
 
On the Malware Detection Problem: Challenges & Novel Approaches
Marcus Botacin
 
Finding Help with Programming Errors: An Exploratory Study of Novice Software...
Preetha Chatterjee
 
Exploratory Study of Slack Q&A Chats as a Mining Source for Software Engineer...
Preetha Chatterjee
 
Test-Driven Development
Ny Fanilo Andrianjafy, B.Eng.
 
Software testing
prasad g
 
Predicting Usefulness of Code Review Comments using Textual Features and Deve...
Masud Rahman
 
The End-to-End Use of Source Code Example: An Exploratory Study ICSM'09
Rylan Cottrell
 
Sound Empirical Evidence in Software Testing
Jaguaraci Silva
 

Similar to On the Distribution of Test Smells in Open Source Android Applications: An Exploratory Study (20)

PDF
Test Anti-Patterns: From Definition to Detection
University of Hawai‘i at Mānoa
 
PPT
Testing
Muni Ram
 
PPTX
Understanding Key Concepts and Applications in Week 11: A Comprehensive Overv...
bahay78365
 
PPTX
Automatic for the People
Andy Zaidman
 
DOCX
Chapter 10 Testing and Quality Assurance1Unders.docx
keturahhazelhurst
 
PPTX
Software Testing 2/5
Damian T. Gordon
 
PPTX
Combinatorial testing ppt
Kedar Kumar
 
PPT
Testing
nazeer pasha
 
PDF
Manual testing interview questions and answers
Testbytes
 
PDF
Test Case Design Techniques in Software Testing_ Elements, Types, and Best Pr...
Jace Reed
 
PPTX
1779905011SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS.pptx
abhivastrad007
 
PPTX
H testing and debugging
missstevenson01
 
PPTX
Bug debug keynote - Present problems and future solutions
RIA RUI Society
 
PDF
Black-Box
Jason Brown, PMP
 
PDF
Exploratory Testing, A Guide Towards Better Test Coverage.pdf
pCloudy
 
PPT
Chapter 8 - Software Testing.ppt
GentaSahuri2
 
PPTX
Testing &ampdebugging
rajshreemuthiah
 
PPT
Orthogonal array approach a case study
Karthikeyan Rajendran
 
PPT
Testing 2 - Thinking Like A Tester
ArleneAndrews2
 
PPTX
Module8_DFMEA_Testing_Innovation_Creativity_v7Innovation_Creativity_v7Deliver...
yatakonakiran2
 
Test Anti-Patterns: From Definition to Detection
University of Hawai‘i at Mānoa
 
Testing
Muni Ram
 
Understanding Key Concepts and Applications in Week 11: A Comprehensive Overv...
bahay78365
 
Automatic for the People
Andy Zaidman
 
Chapter 10 Testing and Quality Assurance1Unders.docx
keturahhazelhurst
 
Software Testing 2/5
Damian T. Gordon
 
Combinatorial testing ppt
Kedar Kumar
 
Testing
nazeer pasha
 
Manual testing interview questions and answers
Testbytes
 
Test Case Design Techniques in Software Testing_ Elements, Types, and Best Pr...
Jace Reed
 
1779905011SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS.pptx
abhivastrad007
 
H testing and debugging
missstevenson01
 
Bug debug keynote - Present problems and future solutions
RIA RUI Society
 
Black-Box
Jason Brown, PMP
 
Exploratory Testing, A Guide Towards Better Test Coverage.pdf
pCloudy
 
Chapter 8 - Software Testing.ppt
GentaSahuri2
 
Testing &ampdebugging
rajshreemuthiah
 
Orthogonal array approach a case study
Karthikeyan Rajendran
 
Testing 2 - Thinking Like A Tester
ArleneAndrews2
 
Module8_DFMEA_Testing_Innovation_Creativity_v7Innovation_Creativity_v7Deliver...
yatakonakiran2
 
Ad

More from University of Hawai‘i at Mānoa (20)

PDF
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
PDF
Exploring Accessibility Trends and Challenges in Mobile App Development: A St...
University of Hawai‘i at Mānoa
 
PDF
The Impact of Generative AI-Powered Code Generation Tools on Software Enginee...
University of Hawai‘i at Mānoa
 
PDF
Mobile App Security Trends and Topics: An Examination of Questions From Stack...
University of Hawai‘i at Mānoa
 
PDF
On the Rationale and Use of Assertion Messages in Test Code: Insights from So...
University of Hawai‘i at Mānoa
 
PDF
A Developer-Centric Study Exploring Mobile Application Security Practices and...
University of Hawai‘i at Mānoa
 
PDF
Building Hawaii’s IT Future Together CIO Council & UH Manoa ICS Collaboration
University of Hawai‘i at Mānoa
 
PDF
Impostor Syndrome in Final Year Computer Science Students: An Eye Tracking an...
University of Hawai‘i at Mānoa
 
PDF
An Exploratory Study on the Occurrence of Self-Admitted Technical Debt in And...
University of Hawai‘i at Mānoa
 
PDF
Performance Comparison of Binary Machine Learning Classifiers in Identifying ...
University of Hawai‘i at Mānoa
 
PDF
Rename Chains: An Exploratory Study on the Occurrence and Characteristics of ...
University of Hawai‘i at Mānoa
 
PDF
A Primer on High-Quality Identifier Naming [ASE 2022]
University of Hawai‘i at Mānoa
 
PDF
Supporting the Maintenance of Identifier Names: A Holistic Approach to High-Q...
University of Hawai‘i at Mānoa
 
PDF
Preparing for the Academic Job Market: Experience and Tips from a Recent F...
University of Hawai‘i at Mānoa
 
PDF
Refactoring Debt: Myth or Reality? An Exploratory Study on the Relationship B...
University of Hawai‘i at Mānoa
 
PDF
A Primer on High-Quality Identifier Naming
University of Hawai‘i at Mānoa
 
PDF
Refactoring Debt: Myth or Reality? An Exploratory Study on the Relationship B...
University of Hawai‘i at Mānoa
 
PDF
Understanding Digits in Identifier Names: An Exploratory Study
University of Hawai‘i at Mānoa
 
PDF
How Do I Refactor This? An Empirical Study on Refactoring Trends and Topics i...
University of Hawai‘i at Mānoa
 
PDF
Using Grammar Patterns to Interpret Test Method Name Evolution
University of Hawai‘i at Mānoa
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Exploring Accessibility Trends and Challenges in Mobile App Development: A St...
University of Hawai‘i at Mānoa
 
The Impact of Generative AI-Powered Code Generation Tools on Software Enginee...
University of Hawai‘i at Mānoa
 
Mobile App Security Trends and Topics: An Examination of Questions From Stack...
University of Hawai‘i at Mānoa
 
On the Rationale and Use of Assertion Messages in Test Code: Insights from So...
University of Hawai‘i at Mānoa
 
A Developer-Centric Study Exploring Mobile Application Security Practices and...
University of Hawai‘i at Mānoa
 
Building Hawaii’s IT Future Together CIO Council & UH Manoa ICS Collaboration
University of Hawai‘i at Mānoa
 
Impostor Syndrome in Final Year Computer Science Students: An Eye Tracking an...
University of Hawai‘i at Mānoa
 
An Exploratory Study on the Occurrence of Self-Admitted Technical Debt in And...
University of Hawai‘i at Mānoa
 
Performance Comparison of Binary Machine Learning Classifiers in Identifying ...
University of Hawai‘i at Mānoa
 
Rename Chains: An Exploratory Study on the Occurrence and Characteristics of ...
University of Hawai‘i at Mānoa
 
A Primer on High-Quality Identifier Naming [ASE 2022]
University of Hawai‘i at Mānoa
 
Supporting the Maintenance of Identifier Names: A Holistic Approach to High-Q...
University of Hawai‘i at Mānoa
 
Preparing for the Academic Job Market: Experience and Tips from a Recent F...
University of Hawai‘i at Mānoa
 
Refactoring Debt: Myth or Reality? An Exploratory Study on the Relationship B...
University of Hawai‘i at Mānoa
 
A Primer on High-Quality Identifier Naming
University of Hawai‘i at Mānoa
 
Refactoring Debt: Myth or Reality? An Exploratory Study on the Relationship B...
University of Hawai‘i at Mānoa
 
Understanding Digits in Identifier Names: An Exploratory Study
University of Hawai‘i at Mānoa
 
How Do I Refactor This? An Empirical Study on Refactoring Trends and Topics i...
University of Hawai‘i at Mānoa
 
Using Grammar Patterns to Interpret Test Method Name Evolution
University of Hawai‘i at Mānoa
 
Ad

Recently uploaded (20)

PDF
Best Web development company in india 2025
Greenusys
 
PPTX
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
PPTX
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
PDF
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
PPTX
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
Best Web development company in india 2025
Greenusys
 
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
Why is partnering with a SaaS development company crucial for enterprise succ...
Nextbrain Technologies
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 

On the Distribution of Test Smells in Open Source Android Applications: An Exploratory Study

  • 1. On the Distribution of Test Smells in Open Source Android Applications: An Exploratory Study Anthony Peruma, Khalid Almalki, Christian D. Newman, Mohamed Wiem Mkaouer, Ali Ouni, Fabio Palomba 29th Annual International Conference on Computer Science and Software Engineering
  • 3. Software maintenance is not cheap! 3 I n t r o d u c t i o n ▸A high-quality system need not be necessarily maintenance-friendly ▸Systems built using poor design/coding practices can meet functional requirements ▸In the long run, such events impact software maintenance - and maintenance is not cheap! ▹ Maintenance consumes 50% to 80% of resources
  • 4. Towards maintenance-friendly code 4 I n t r o d u c t i o n ▸Researchers and industry have defined and created approaches and tools to detect code in need of refactoring ▹ Design/code smells - Cohesion, Coupling, God Class, etc. ▹ Tools - FindBugs, PMD, Checkstyle, etc. ▸Smells make code harder to understand and make it more prone to bugs and changes ▸Research and tools have been primarily on production code
  • 5. Test Smells 5 I n t r o d u c t i o n ▸Test code, like production code, is subject to smells ▸Formally introduced in 2001 with 11 smell types ▸Inclusion of additional smell types through the years, analysis of their evolution and longevity, and elimination patterns ▸Tools to detect specific smell types ▸Studies on traditional Java applications
  • 6. “2.6 million apps available on Google Play as of Q4 2018
  • 7. Objective Insight into the unit testing practices of Android app developers with the aim of providing developers a mechanism to improve unit testing code 7 I n t r o d u c t i o n
  • 8. Contribution 8 I n t r o d u c t i o n & O b j e c t i v e s Open-Source Test Smell Detection Tool Understanding of Test Smells in Android apps Expansion of Test Smell Types Replication Package Availability
  • 9. Research Questions 9 I n t r o d u c t i o n RQ 02 What is the general trend of test smells in Android apps over time? ▹ When are test smells first introduced into the project? ▹ How do test smells exhibited by the apps evolve over time? RQ 01 How likely are Android apps to contain unit test smells? ▹ Are apps, that contain a test suite, prone to test smells? ▹ What is the frequency and distribution of test smells in apps? ▹ How does the distribution of smell types in Android apps compare against traditional Java applications?
  • 11. Proposed Test Smells 11 T e s t S m e l l s ▸ Conditional Test Logic ▸ Constructor Initialization ▸ Default Test ▸ Duplicate Assert ▸ Empty Test ▸ Exception Handling ▸ Ignored Test ▸ Magic Number Test ▸ Redundant Print ▸ Redundant Assertion ▸ Sleepy Test ▸ Unknown Test
  • 12. Practicability 12 T e s t S m e l l s 120smelly unit test files 100software systems 120software developers 41.7%response rate Are our proposed smells indicative of problems?
  • 13. Conditional Test Logic 13 T e s t S m e l l s ▸ Conditions within the test method will alter the behavior of the test and its expected output ▸ Developers agree on the negative impact on code comprehension ▸ However, outright removal may not always be applicable – decide on a “case by case basis” I actually have no idea why that for loop is there. It doesn’t do anything but run the test 1000 times, and there’s no point in that. I’ll remove it.
  • 14. Constructor Initialization 14 T e s t S m e l l s ▸ Initialization of fields should be in the setUp() method (i.e., test fixtures) ▸ Most developers are aware of test fixtures ▸ Developers unanimously agree on using test fixtures ▸ Reasons for not using test fixtures include “laziness” and being “sloppy” I have already made this change since you pointed it out so the code is clearer now
  • 15. Default Test 15 T e s t S m e l l s ▸ Default test class meant to serve as an example ▸ Should either be removed ▸ A test-first approach will force developers to remove the file ▸ Unanimous agreement among developers that the file “serves no concrete purpose” and that it may lead to confusion Removed useless example unit test
  • 16. Duplicate Assert 16 T e s t S m e l l s ▸ The same condition is tested multiple times within the same test method ▸ The name of the test method should be an indication of the test ▸ Mixed responses - some developers preferred to split the assertion statement into separate methods I might enforce it on some bigger projects
  • 17. Empty Test 17 T e s t S m e l l s ▸ When a test method has no executable statements ▸ JUnit will indicate that the test passes even if there are no executable statements present in the method body ▸ Unanimous agreement among developers that such test methods should be removed from the test suite Yes definitely should be removed
  • 18. Exception Handling 18 T e s t S m e l l s ▸ Passing or failing of a test method is explicitly dependent on the production method throwing an exception ▸ Developers should utilize JUnit’s exception handling features to automatically pass/fail
  • 19. Ignored Test 19 T e s t S m e l l s ▸ Ignored test methods result in overhead with regards to compilation time and an increase in code complexity and comprehension ▸ Mixed responses - investigate problems or serve as a means for new developers “to understand behavior” would not tolerate to have ignored tests in the code
  • 20. Magic Number Test 20 T e s t S m e l l s ▸ Test method contains unexplained and undocumented numeric literals ▸ Developers agree that the use of constants over magic numbers improve code readability/understandability ▸ Not a blanket rule - a constant should only be used so that its “name adds useful information” If the numerical value has a deeper meaning (e.g. flag, physical constant, enum value) then a constant should be used.
  • 21. Redundant Assertion 21 T e s t S m e l l s ▸ Assertion statements that are either always true or false ▸ Common reason for the existence of this smell is due to developer mistakes ▸ Developers confirmed that such code “is not needed”, “bad style” and “should probably be removed” ▸ Might exist to support edge cases
  • 22. Redundant Print 22 T e s t S m e l l s ▸ Unit tests are executed as part of an automated script ▸ They can consume computing resources or increase execution time ▸ Unanimous agreement that print statements do not belong in test suites ▸ A common reason for the existence of this smell is due to developer debugging a waste of resources (cpu+disk space)
  • 23. Sleepy Test 23 T e s t S m e l l s ▸ Explicitly causing a thread to sleep can lead to unexpected results as the processing time for a task differs when executed in various environments and configurations ▸ Developers confirmed that there are risks (i.e., inconsistent results) involved with causing a thread to sleep the alternative requires more code
  • 24. Unknown Test 24 T e s t S m e l l s ▸ The assertion statement helps to indicate the purpose of the test ▸ JUnit will show the test method as passing ▸ Majority of the developers are in favor of having assertion statements in a test method ▸ Missing assertions were due to mistakes It looks like just sloppy coding there. I'll look to fix that test
  • 25. TSDetect ▸ Open-source, Java-based, static analysis ▸ Available as a standalone jar and requires a list of file paths as input ▸ Utilizes an abstract syntax tree to parse and detect test smells ▸ Detects 19 test smells (12 proposed + 7 existing) ▸ Average F-Score of 96.5% 25 T e s t S m e l l s High-level architecture of TSDetect
  • 27. Data Collection Phase 27 E x p e r i m e n t M e t h o d o l o g y F-Droid Repositories Data Mining Tools Mining Output 2,011cloned apps 1,037,236 commits 6,379,006 java files affected by commits +3.5 GB java files collected
  • 28. Detection Phase 28 E x p e r i m e n t M e t h o d o l o g y Test File Detection Tool Test Smell Detection Tool Syntactically correct test files with 1 or more test methods Detected test smells 656analyzed apps 206,598 detected test files 1,187,055 analyzed test methods 175,866 test files with 1 or more smells
  • 30. RQ1 – Test Smell Occurrence Test Smell Occurrence & Distribution ▹ 97% of the analyzed apps contained test smells ▹ Assertion Roulette occurred the most (in over 50% of the analyzed apps and test files) ▹ All smell types had a high co-occurrence with Assertion Roulette ▹ Similar distribution of test smells between Android and non-Android applications 30 A n a l y s i s & D i s c u s s i o n
  • 31. RQ1 – Test Smell Occurrence 31 0.00% 2.00% 4.00% 6.00% 8.00% 10.00% 12.00% 14.00% 16.00% 18.00% S m e l l T y p e D i s t r i b u t i o n S m e l l T y p e O c c u r r e n c e A n a l y s i s & D i s c u s s i o n
  • 32. RQ1 – Test Smell Occurrence 32 A n a l y s i s & D i s c u s s i o n S m e l l T y p e C o - O c c u r r e n c e
  • 33. RQ2 – Test Smell Trend 33 A n a l y s i s & D i s c u s s i o n Test Smell Introduction ▹ The first inclusion of a smelly file occurs approximately 23% of the way through the total app commits ▹ A test file is added with 3 smell types ▹ Assertion Roulette is the frequently the first smell type introduced ▹ Smells exhibited by a file remains constant throughout all updates to the file
  • 35. Summary 35 C o n c l u s i o n ▸ Extended the catalog of known unit test smells ▸ Open source test smell detection tool ▸ A study of 656 Android apps showed a high prevalence of test smells in test suites ▸ Smells are introduced early on into the codebase and exist during the lifetime of the app ▸ Comprehensive project website: https://testsmells.github.io