universiti tun hussein onn malaysia -...

46
UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS TEST SUITE REDUCTION IN ANDROID APPLICATION USING REFACTORING ACADEMIC SESSION : 2015/2016 I, MARYAM TEMITAYO AHMED agree to allow this Doctoral Thesis to be kept at the Library under the following terms: 1. This Doctoral Thesis is the property of Universiti Tun Hussein Onn Malaysia. 2. The library has the right to make copies for educational purposes only. 3. The library is allowed to make copies of this report for educational exchange between higher educational institutions. 4. ** Please Mark (√) CONFIDENTIAL (Contains information of high security or of great importance to Malaysia as STIPULATED under the OFFICIAL SECRET ACT 1972) RESTRICTED (Contains restricted information as determined by the Organization/institution where research was conducted) FREE ACCESS _________________________ Approved by, __________________________ (WRITER’S SIGNATURE) (SUPERVISOR’S SIGNATURE) Permanent Address : No. 5 Jalan 3, UTHM Apartment Taman Melewar, UTHM, 86400, Parit Raja, Batu Pahat, Johor. Date: ___________________ PROF. DR. ROSZIATI IBRAHIM Date : ________________________ 9 NOTE: ** If this Doctoral Thesis is classified as CONFIDENTIAL or RESTRICTED, Please attach the letter from the relevant authority/organization stating reasons and duration for such classifications.

Upload: lequynh

Post on 13-Feb-2018

221 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

UNIVERSITI TUN HUSSEIN ONN MALAYSIA

STATUS CONFIRMATION FOR DOCTORAL THESIS

TEST SUITE REDUCTION IN ANDROID APPLICATION USING REFACTORING

ACADEMIC SESSION : 2015/2016 I, MARYAM TEMITAYO AHMED agree to allow this Doctoral Thesis to be kept at the Library under the following terms: 1. This Doctoral Thesis is the property of Universiti Tun Hussein Onn Malaysia. 2. The library has the right to make copies for educational purposes only. 3. The library is allowed to make copies of this report for educational exchange between

higher educational institutions. 4. ** Please Mark (√)

CONFIDENTIAL

(Contains information of high security or of great importance to Malaysia as STIPULATED under the OFFICIAL SECRET ACT 1972)

RESTRICTED

(Contains restricted information as determined by the Organization/institution where research was conducted)

FREE ACCESS

_________________________

Approved by,

__________________________ (WRITER’S SIGNATURE)

(SUPERVISOR’S SIGNATURE)

Permanent Address : No. 5 Jalan 3, UTHM Apartment Taman Melewar, UTHM, 86400, Parit Raja, Batu Pahat, Johor. Date: ___________________

PROF. DR. ROSZIATI IBRAHIM

Date : ________________________

NOTE: ** If this Doctoral Thesis is classified as CONFIDENTIAL or RESTRICTED,

Please attach the letter from the relevant authority/organization stating reasons and duration for such classifications.

Page 2: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

This thesis has been examined on 27 April 2016

and is sufficient in fulfilling the scope and quality for the purpose of awarding

Degree of Doctor of Philosophy.

Chairperson:

PROF. DR. MUSTAFA BIN MAT DERIS

Faculty of Computer Science and Information Technology

Universiti Tun Hussein Onn Malaysia

Examiners:

PROF. DR. ALI SELAMAT

Faculty of Computer Science and Information Systems

Universiti Teknologi Malaysia

DR. MOHD NAJIB BIN MOHD SALLEH

Faculty of Computer Science and Information Technology

Universiti Tun Hussein Onn Malaysia

Page 3: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

TEST SUITE REDUCTION IN ANDROID APPLICATION USING

REFACTORING

MARYAM TEMITAYO AHMED

A thesis submitted in

fulfillment of the requirement for the award of the

Doctor of Philosophy in Information Technology

Faculty of Computer Science and Information Technology

Universiti Tun Hussein Onn Malaysia

JULY 2016

Page 4: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

ii

I hereby declare that the work in this thesis is my own except for quotations and

summaries which have been duly acknowledged

Student : .........................................................

MARYAM TEMITAYO AHMED

Date : .........................................................

Supervisor : .........................................................

PROF. DR. ROSZIATI IBRAHIM

Co Supervisor : .........................................................

DR. NORAINI IBRAHIM

Page 5: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

DEDICATION

I dedicate this thesis to Almighty Allah, the cherisher and the sustainer who has made my journey all worth it. And to my lovely parent, thanks for always being there for me. To my husband, I appreciate your love and support. And for the two precious gifts Allah blessed me with during the course of study, I love you so much.

iii

Page 6: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

iv

ACKNOWLEDGEMENT

All praises, thanks and adorations are due to Almighty Allah. I am more than

grateful to Him for seeing me through this course. I am deeply indebted to my

supervisor Prof. Dr. Rosziati Ibrahim whose help, stimulating suggestions, useful

critiques and encouragement helped me in all the times of study and analysis of

the pre and post research period. My heart felt appreciation to my co-supervisor,

Dr. Noraini Ibrahim, your support, patience and assistance is well appreciated. I

am indeed grateful. My appreciation to the members of staff of the Faculty of

Computer Science and Information Technology (FSKTM) and Centre of Graduate

Studies (CGS) of Universiti Tun Hussein Onn Malaysia (UTHM) for providing a

comfortable environment that enhanced my study. I am deeply indebted to the Office

of Research, Innovation, Commercialization and Consultancy Management (ORICC)

for sponsoring this research under the vot. 1256. I would like to express my gratitude

to Dr. Rasheeda Olanrewaju, Mrs. Remi Ahmed, Mr Abiola Balogun, Aisha Ishaq,

Maryam Salihu, Hauwa Atiku, Saima Anwar Lashari, my neighbours in Malewar and

my colleagues. You all have made the journey worthwhile. Special thanks goes to

my friends both home and abroad. Thanks for being part of my story. To my family;

uncles, aunties, cousins and in-laws, thank you all for your moral support and words

of encouragement. You are well appreciated. I am without any doubt indebted to my

siblings. Thanks for touching my life in a special way. My utmost gratitude goes to my

parent and mother-in-law. You are indeed a blessing to me. Thank you for believing

in me. And to all my lovely nieces; thanks for being my source of inspiration. My

heartfelt appreciation goes to my darling husband and lovely sons for their support and

encouragement during the course of this research. Your support and co-operation can

never be overestimated.

Page 7: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

v

ABSTRACT

The vast increase in demand for android applications has made android application

testing inevitable. The android open source feature has led to developers of unknown

level of expertise developing the application, thus raising concerns on quality issues.

Currently, android applications are found lagging in the area of testing. Test case

generation is the most important and challenging area of software testing. Test cases

tend to be large in number as redundant test cases are generated due to the presence

of code smells in the software. Code smells are unnecessary codes, as a result of poor

design or implementation. Several approaches have been proposed in the past by both

academy and industrial researchers to tackle the high number of generated test cases

in android applications, including test case minimization and prioritization technique.

Nonetheless, these approaches are reactive rather than proactive. The technique used

in this study is to apply code refactoring before test case generation to avoid redundant

test cases from being generated. To achieve this, the detection of smells was done,

followed by refactoring of detected smells. Test cases were then generated from the

refactored code. More explicitly, this research presents three rules for detection of

three code smells; lazy class, small method and duplicate, and three rules for their

refactoring. The rules were implemented in a tool named DART (Detection and

Refactoring Tool) to refactor the android source code for the reduction of test cases.

The resultant source code is compared with the original source code by generating a

number of branches, branch coverage and complexity using Clover. The results of this

research show a reduction of about 7.7% in the cyclomatic complexity of the source

code, while increasing the branch coverage with up to 9.2% increment. Also, there is a

28% reduction in the number of test cases generated. These show that refactoring can

be used to reduce redundant test cases.

Page 8: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

vi

ABSTRAK

Permintaan yang meningkat hebat terhadap aplikasi android telah menyebabkan

pengujian android sesuatu yang tidak dapat dielakkan. Ini kerana, ciri sumber terbuka

android mengundang pembangun sistem yang tidak diketahui kepakarannya turut

membangunkan aplikasi ini dan seterusnya menimbulkan kebimbangan terhadap isu

kualiti. Pada masa ini, aplikasi android masih dilihat ketinggalan dalam bidang

pengujian. Penghasilan kes ujian ialah bidang pengujian perisian yang paling

penting dan mencabar. Penghasilan bilangan kes ujian yang besar berpunca daripada

penghasilan kes ujian lewah yang terhasil daripada kewujudan hiduan kod atau

code smells dalam perisian. Hiduan kod ialah kod yang tidak perlu yang berpunca

daripada reka bentuk dan pelaksanaan yang tidak baik. Beberapa pendekatan telah

dicadangkan oleh para penyelidik akademik dan industri bagi menangani kebanjiran

kes ujian yang dihasilkan dalam aplikasi android, termasuk teknik peminimuman

dan pengutamaan kes ujian. Walau bagaimanapun, pendekatan ini lebih bersifat

reaktif dan bukan proaktif, lantas menyebabkan pembaziran masa dan usaha. Teknik

yang dicadangkan adalah dengan menggunakan pemfaktoran semula kod sebelum

kes ujian dihasilkan untuk mengelakkan kes ujian dihasilkan secara lewah. Untuk

mencapai perkara ini, pengesanan hiduan dilakukan, diikuti dengan pemfaktoran

semula kod hiduan yang dikesan. Kes ujian kemudiannya dijana daripada kod terfaktor

semula tersebut. Secara lebih jelasnya, kajian ini membentangkan tiga peraturan

untuk mengenal pasti tiga jenis hiduan kod, iaitu lazy class, small method dan

duplicate dan tiga peraturan untuk pemfaktorannya semula. Peraturan- peraturan ini

dilaksanakan dalam alat yang dinamakan DART (Detection and Refactoring Tool)

untuk memfaktorkan semula kod sumber android bagi mengurangkan kes ujian.

Hasil kod sumber yang telah difaktorkan dibandingkan dengan kod sumber asal dan

Page 9: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

vii

bilangan, liputan cabang serta kekompleksannya dijana menggunakan Clover. Hasil

kajian menunjukkan pengurangan kekompleksan siklomatik kod sumber sebanyak

7.7% serta meningkatkan kualiti kes ujian melalui liputan cabang sebanyak 9.2%.

Selain itu, terdapat pengurangan sebanyak 28% dalam jumlah kes ujian yang dijana.

Ini menunjukkan pemfaktoran kod semula boleh menjadi pendekatan alternatif untuk

mengurangkan kes ujian lewah.

Page 10: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

CONTENTS DECLARATION ii DEDICATION I iii ACKNOWLEDGEMENT iv ABSTRACT v ABSTRAK vi CONTENTS viii

LIST OF TABLES xiii LIST OF FIGURES xiv

LIST OF ALGORITHMS xvi LIST OF SYMBOLS AND ABBREVIATIONS xvii LIST OF APPENDICES xix

CHAPTER 1 INTRODUCTION 1 1.1 Problem Statement 3 1.2 Research Question 5 1.3 Research Objectives 5 1.4 Scope Of Study 5 1.5 Limitations and Assumptions 6 1.6 Significance of Research 7 1.7 Thesis Outline 7

CHAPTER 2 LITERATURE REVIEW 10 2.1 Overview of Mobile Application 10 2.2 Android Operating System and Architecture 12 2.3 Software Testing 14

viii

Page 11: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

ix

2.3.1 Classification of Software Testing 15

2.3.2 Stages of Software Testing 15

2.4 Types of Test Case Reduction Techniques 18

2.4.1 Test Case Minimization 19

2.4.2 Test Case Prioritization 24

2.5 Systematic Literature Review on Test case Reduc-

tion 28

2.5.1 Related Work 31

2.5.2 Methodology 33

2.5.3 Search strategy 33

2.5.4 Results and Findings 34

2.6 Code Smell Detection 37

2.6.1 Type of Code Smells 39

2.7 Refactoring 41

2.7.1 Move Method 42

2.7.2 Move Field 43

2.7.3 Extract Class 44

2.7.4 Inline Class 44

2.7.5 Inline Method 45

2.8 Detection and Refactoring Tools 46

2.9 Cyclomatic complexity 49

2.10 Chapter Summary 50

CHAPTER �RESEARCH3 METHODOLOGY 51

3.1 Research framework 51

3.2 Design of Code Smell Detection Rules 53

3.3 Design of Refactoring Rules for Detected Smells 55

3.4 Implementation of detection and Refactoring Rules

in Tool Environment 58

3.4.1 Agglomerative hierarchical clustering al-

gorithm 59

3.4.2 Karb-Rabin Algorithm 60

3.4.3 Development of DART 62

3.4.3.1 Eclipse Framework 62

3.4.3.2 Menus, views and editors 63

3.4.3.3 Plug-ins 64

3.4.3.4 Refactoring in Eclipse 65

3.4.3.5 Abstract Syntax trees 66

3.4.3.6 ASTVisitor 67

Page 12: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

x

3.5 Architecture Overview of DART 67

3.6 Evaluation and Validation of DART using Cyclo-

matic Complexity, Branch Coverage and Test Case

Generation 69

3.7 Chapter Summary 71

CHAPTER �DESIGN4 OF CODE SMELL DETECTION ANDREFACTORING RULES 72

4.1 Introduction 72

4.2 Research Background 73

4.3 Proposed Solutions 75

4.4 Design of Code Smell Detection Rules 77

4.4.1 Lazy Class Detection Rules 79

4.4.2 Small Method Detection Rules 81

4.4.3 Duplicate Detection Rules 83

4.5 Design of Refactoring Rules for Detected Code

Smells 84

4.5.1 Refactoring Lazy Class 84

4.5.2 Refactoring Small Method 85

4.5.3 Refactoring Duplicate 87

4.6 Evaluation of rules 96

4.7 Chapter Summary 98

CHAPTER 5 IMPLEMENTA �TIONOF DETECTION AND REFAC-TORING ALGORITHM IN DART 99

5.1 Implementation of detection rules in DART 99

5.1.1 Detection of the lazy class code smell 100

5.1.2 Detection of small method code smell 101

5.1.3 Detection of duplicate code smell 102

5.2 Implementation of refactoring rules in DART 102

5.2.1 Applying the Inline Class Refactoring 102

5.2.2 Applying the Inline method Refactoring 103

5.2.3 Applying the extract clone refactoring 104

5.3 Result and Evaluation of Dart 105

5.3.1 Analysis of Case Studies 105

5.3.1.1 ALogcat 106

5.3.2 Results of Alogcat 106

Page 13: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

xi 5.3.2.1 Detection of Lazy Class in Alogcat 107 5.3.2.2 Detection of Small method in alogcat 108 5.3.2.3 Detection of duplicate in alog- cat 108 5.3.2.4 Refactoring detected lazy class in alogcat 109 5.3.2.5 Refactoring of detected small method 110 5.3.2.6 Refactoring of Detected Dupli- cate in Alogcat 112 5.3.3 Comparison of Result between Imple- menting DART in Alogcat and the Original Code 112 5.3.4 Branch Coverage Results for Refactored Classes 113 5.3.5 Validation of DART using test case generation 115

5.4 Chapter Summary 117 CHAPTER 6 RESULT AND EVALUATION OF DART 119

6.1 User Acceptance Testing for DART 119 6.1.1 Overview 120 6.1.1.1 Assumptions 120 6.1.1.2 Constraints 120 6.1.1.3 Summary Assessment 120 6.1.2 Detailed Test Results 122 6.1.3 Recommendations 125

6.2 Comparison of DART technique and other past researchers technique 125 6.2.1 Comparison of DART based on smell detection and refactoring 125 6.2.2 Comparison of DART based on test path reduction and branch coverage 129

6.3 Chapter Summary 131

Page 14: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

xiiChapter 7 CONCLUSION AND FUTURE WORK 132

7.1 Research Summary 1327.2 Achievement of Objectives 133

7.2.1 Objective 1: Design of detection rules for lazy class, small method and duplicate code smells 133 7.2.2 Objective 2: Design of refactoring rules to refactor the three detected code smells in Objective 1 134 7.2.3 Objective 3: Implementation of the detection and refactoring rules into the DART tool 135 7.2.4 Objective 4: Evaluate and validate DART by

comparing the generated number of branches, cyclomatic complexity, branch coverage and test cases generated from original code with the refactored codes of an android applications. 136

7.3 Contribution of the Study 1367.4 Recommendations for Future Work 1377.5 Summary 138

REFERENCES 139

APPENDICES A – E 153 – 173

Page 15: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

LIST OF TABLES 2.1 Classification of Software Testing 15 2.2 Review on Test Case Reduction Techniques 28 2.3 Stages of paper search 34 2.4 Related Works on Code Smell and Refactoring 46 2.5 Code Smell Detection Tools 48 2.6 Code Smell Support 48 3.1 An Overview of the Alogcat Analyzed Classes 70 4.1 Overview of code smell properties and their formal logical representation in DART 77 4.2 Definition with the respective detection and refactoring rules 89 5.1 Analysis of alogcat to detect lazy class 107 5.2 Comparison of result for lazy class, small method, duplicate and original code for alogcat before and after refactoring 1135.3 Branch coverage results for refactored classes 1145.4 Refactored classes in each code smell 1155.5 Test cases generated from original Alogcat source code 1165.6 Test cases generated from refactored Alogcat source code 1176.1 Test Case Summary Results 1226.2 Code Smell Detection Tools 1286.3 Code Smell Support 128 6.4 Comparison of DART with other detection and refactoring techniques 128 6.5 Comparison of DART with other test case reduction techniques 131 7.1 Summary of Research Contribution 137

xiii

Page 16: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

LIST OF FIGURES 2.1 The Growth Rate of Mobile Phones over the Years 11 2.2 The Android Market Growth 11 2.3 Android Architecture [48] 13 2.4 Stages in Software Testing 16 3.1 Flowchart of Research Process 52 3.2 Research Framework to Detect and Refactor code smells 53 3.3 Test path illustrating lazy class 55 3.4 Duplicate in a source code 56 3.5 Test path of duplicated code 57 3.6 Test path illustrating refactored lazy class 57 3.7 Test path of refactored duplicated code 58 3.8 Architecturally significant usecases of DART 69 4.1 Refactoring Process 76 4.2 Inline Class to Refactor Lazy Class 84 4.3 Example of Lazy Class 90 4.4 LogSaver.java 91 4.5 Lock.java 92 4.6 Example of Small Method 93 4.7 Duplicate in SaveReceiver.java 94 4.8 Duplicate in ShareReceiver.java 95 4.9 Extracted Class RequestReceiver.java 95 4.10 Alogcat Application before and after refactoring 96 4.11 Arithmetic duplicated code 97 4.12 Arithmetic View before and after refactoring 98 5.1 Overview of Alogcat Application 106 5.2 Detected Lazy Class Detection Table 107 5.3 Detected Small Method Detection Table 108 5.4 Detected Duplicate Detection Table 108 5.5 Branch and Complexity in Alogcat 109

xiv

Page 17: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

��

Page 18: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS
Page 19: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS
Page 20: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS
Page 21: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS
Page 22: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS
Page 23: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

CHAPTER 1

INTRODUCTION

The idea of quality assurance has been in existence even before the advent of software

[3], hence quality of products including software has been a subject of keen interest

from past till present. Quality has been an issue as long as human has been producing

products [3]. To endorse the quality of software, software testing becomes a requisite.

Software testing is an important and major area of Software Quality Assurance (SQA).

Software testing is the process of executing a program with the purpose of finding

faults. Testing include effort to find defects but does not include getting solution to

fixing the defects. This is the difference between testing and quality assurance as

quality assurance is not limited to developing the test plan but also include testing,

preventing and fixing the faults found during the process of testing. However, testing

can cover different areas such as specification, design and implementation testing.

Implementation testing which deals with the working system of the software is most

time referred to as software testing [3].

Software testing as an aspect of SQA differs in mobile application testing. The

uniqueness of mobile application testing as discussed in [4][5][6] as related to the

structure of the mobile application itself include the limited resources, rapid growth in

advancement, frequent updates, screen size and processing power. Of the distinctive

Page 24: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

2

properties of mobile applications, frequent update has led to minimal testing, hence,

increasing the chance of low quality applications. Mobile applications work on

different platforms which include windows, iOS and Android. Android specifically

has been going through a rapid growth and frequent updates.

Android applications, often referred to as Android apps or apps, are application

software developed to run on smartphones, tablet and other devices running on Android

OS [7]. The demand and market of this application continue to rise as the capabilities

of the mobile phone is limitless. Initially, the mobile apps are known to perform basic

tasks such as receiving and sending emails and access to the internet. Over the years,

the scope of activities being done on the mobile is overwhelming and this is dependent

on the available apps in the market. The number of Android applications available

today is alarming. There are more than 1.6 million Android applications available for

download in Google [8]. Over a million Android new devices are activated each day

with over a billion apps downloaded each month [9].

According to the statistics on Appbrain website [10], 37% of the Android

apps are categorized as low quality with less than 3 ratings. Though Google takes

out applications from the market on a quarterly bases if found to be of bad quality.

Nonetheless, these low quality applications are in the market for a while and users

are able to download and use them within that period they were in market [7]. Some

developers go further to reuse these bad apps to develop a new one hence, increasing

the impact of the low quality apps. With about 85% of free Android apps [10], Android

remains the most downloaded mobile apps [8]

The poor quality of the Android apps can be attributed to the lack of sufficient

testing process due to its rapid development practice [11]. Android developers tend

to ignore good testing practices as it is considered time consuming, expensive and

with lots of repetitive tasks. To improve the quality of the apps, more attention

needs to be given to effective approaches and tools for testing Android apps [11].

Test case generation is a core aspect of software testing. Improving the quality of

test cases generated improves the quality of testing. Android test case libraries can

Page 25: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

3

be unnecessary filled with redundant test cases and clones as a result of clones and

redundant codes present in the source code [12]. These clones and redundant codes

can be referred to as code smells.

Code smells are source code related patterns as a result of bad design and

programming actions [13]. Code smells do not affect external attributes of the program

as in the case of programming error. However, they remain a threat in maintainability

of the software. Detection of code smells indicate areas in a source code that

refactoring could be done to improve the software quality and maintainability [13].

Refactoring is defined as a practice aim at restructuring an existing code by changing

the internal structure of the code without affecting the external functionality [14].

Not refactoring the code only increases difficulty in its maintainability including the

testability [13], although, it does not stop the code from working properly. Thus, it can

be said that refactoring helps to improve the maintainability and quality of the software.

Given that testing is considered the most expensive process of software development

and that the ratio of testing cost over total software development cost is increasing

as time passes [15], refactoring could save money in the end. Since code smells are

defined in terms of their programming styles, they can be detected using static analysis

(code analysis), unlike behavioral style where dynamic information is needed. This

implies that a tool for detecting code smells does not need to run the application. It

only needs access to the source code and possibly libraries that are referenced by the

source code. A good technique to find code smells and refactor the code will help

improve the maintainability and quality of the systems.

1.1 Problem Statement

As important as software testing is, many android developers avoid it due to time

and effort involved as a result of redundancies. Two different commercial crash

reporting services presented the results of their big data analyses of millions of crash

reports in consecutive years at DroidCon in 2012 and 2013. The top root cause of

this can be associated to lack of sufficient testing [16]. The consistency of these

Page 26: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

4

failures were further corroborated by a robustness evaluation of Android inter-process

communication (IPC) study done by [17] in late 2012. Hence, there is need to improve

testing process in android application.

Test case generation is the first and most challenging aspect of software testing.

Test cases are assumed to mirror the original software under test (SUT). Hence, the

effectiveness of test case generated can be associated to the quality of the source

code of system under test [12]. Improving the quality and reliability of test cases

generated improves the quality of testing [18], and so is an improvement in source

code can enhance the quality of test case generated. Presence of code smells in

android application source code has led to many redundant and avoidable test cases

being generated. This eventually increases the cost and effort in testing the application

[19]. Researchers in both academy and industry are making effort in minimizing the

effect of the redundant test case generated [20].

The two well-known approaches presently being looked into are test case

prioritization [21][22][23] and test case minimization [20][24][25]. In these two

approaches, the test cases are generated which includes the redundant test cases. Most

of these approaches are well established in the area of regression testing. Theres less

attention given to redundancy avoidance in a newly developed application. Hence,

there is need for a technique that averts redundant test cases from being generated

in a new system. Asaithambi and Jarzabek [12] suggested refactoring as a possible

solution that can be explored in the future to reduce generating redundant test cases.

Refactoring the source code can eliminate code smells that could generate redundant

test cases. On the other hand, most refactoring approaches lack a clear definition of the

technique or the evaluation [26].

This research nonetheless, applies the refactoring technique to refactor the

android source code to eliminate duplicates, lazy classes and small methods code

smells that could possibly lead to generating redundant test cases. This is achieved

by formalizing the detection and refactoring rules for the three code smells in focus.

The formalization is done using set notation. Each code smell with its detection and

Page 27: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

5

refactoring technique is specified. This formalization is done to clearly state and define

the detection and refactoring rules as most refactoring approaches still lack a clear

definition [26]. Each of the detected smell has its own refactoring rule. Manually

refactoring is time consuming and takes lots of effort [26]. Automating the process

is indispensable. Hence, a tool named DART (Detection and Refactoring Tool) is

developed to implement the detection and refactoring rules. DART is evaluated using

an android application source code by generating branch coverage and cyclomatic

complexity from both the original and the refactored source code using Clover for

android and the results are compared. Test cases are also generated before and after

refactoring to see the effect of the refactored source code.

1.2 Research Question

Having discussed the problem statement, the research questions that guided this

research are as follows:

i How is test case redundancy presently handled ?

ii How can refactoring be used to eliminate redundant test cases ?

iii Has refactoring reduced redundancy in test case ?

1.3 Research Objectives

The major objectives of the study are as follows:

i to propose the detection rules for lazy class, small method and duplicate code

smells,

ii to propose the refactoring rules to refactor the detected code smells in (i),

iii to implement the detection and refactoring rules in (i) and (ii) respectively into

a tool environment named Detection and Refactoring Tool (DART).

iv to evaluate DART by comparing generated cyclomatic complexity, branch

coverage and number of test cases generated from original and refactored

codes of an android application.

Page 28: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

6

1.4 Scope Of Study

This research focuses on refactoring android application from the source code to

reduce the redundant test cases by reducing the branches or test path and cyclomatic

complexity for structural testing. Test path and cyclomatic complexity are generated

from the refactored code based on functional testing using scenario cases. The drive of

test case reduction is to reduce cost while maintaining fault detection capability [27].

The concentration is to come up with detection and refactoring rules that can improve

the quality of the source code, thereby generating test cases with reduced redundancy.

The rules are implemented in a tool named DART to automate the detection and

refactoring process. To validate DART, an android source code is refactored using

DART and clover is used to generate the number of branches and complexity in each

of the original and refactored codes. The branch coverage is calculated to ensure the

quality of the test cases is maintained.

1.5 Limitations and Assumptions

Case study is an important technique of undertaking research; the intensive analysis

of a particular case (or instance) will give an insight to a logical approach of solving

the real world problem. The ability to simulate the actual problem in the most suitable

and direct form provides a systematic solution to the problem. Therefore, this research

made several assumptions about open source Android applications. First, it assumed

that the quality of open source applications fairly represent Android applications as

a whole. Some developers believe that open source applications tend to be more

reliable based upon the popular expression given enough eyeballs, all bugs are shallow

known as the Many Eyeballs concept [28] of open source development. Android

markets, however, are very active. New applications get added frequently as others

grow inactive and fall unsupported, which emphasize the generalized evolution of

open source Android applications. Hence, open source application is used for case

study in this research. The second assumption made is based on the effect of branches

Page 29: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

7

and cyclomatic complexity in test case generation. Each test path is assumed to have

same weightage in terms of effort and cost. According to Wong, Horgan, London and

Marthur, usually referred to as WHLM study [29], for the purpose of research, it is

allowed to say that each test case has equal cost. Hence, reduction in number of test

paths generated reduces cost and effort. Finally, four other assumptions are made as

regards the refactoring process:

• refactoring being applied will not alter the semantics of the program under test.

• Applying refactoring is safe and does not inject new bugs.

• The effort involved in refactoring is aligned with the resulting quality

improvements. In other words, the improvement is worth the investment.

• Refactoring does not significantly reduce any other quality features, particularly,

maintainability, energy and time execution.

1.6 Significance of Research

At the end of this research, the proposed technique generates source codes with

reduced test path and reduced cyclomatic complexity. This implies that it reduces

cost and effort in testing by eliminating repetitive tasks. Reduction in test path

reduces time as well as cost [30]. Inadequate and ineffective testing is responsible for

numerous difficulties with software reliability. On the other hand, the complexity of

contemporary software applications makes exhaustive testing difficult [31]. Hence,

reducing the test path to barest minimum increases the software reliability. Most

refactoring techniques have been said to lack a clear definition [26] and this has

prevents continuity in this area of research. A formal definition of detection and

refactoring rules are presented to give a clear definition of the approach used in this

study

Page 30: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

8

1.7 Thesis Outline

The rest of this thesis is organized into the following chapters.

Chapter 2 presents the literature review covering the scope of this research as it

discusses android application, test case reduction and refactoring. Mobile application

is briefly discussed while focusing on Android application and its architecture. A

general overview on software testing is also presented including the types of testing.

The five stages in software testing are also mentioned in the chapter and this leads us

to the focus of the research on the first stage, which is test case generation. Presently,

there are basically two approaches to test case reduction and they are: test case

minimization and test case prioritization. A systematic literature review is presented

on test case reduction techniques. As the main goal of this study is to reduce test case

generation through source code refactoring, the literature review includes a review on

past researches on detection and refactoring of smells. Different types of code smells

are discussed including the ones detected in this research. Refactoring approaches are

also discussed.

Chapter 3 describes four (4) main activities involved in this research, which

include formalization of code smell detection rules, formalization of refactoring rules

for detected smells, implementation of the detection and refactoring rules in tool

environment and evaluation of the developed tool.

Chapter 4 presents the design and formalized definition of the code smells

and their respective refactoring techniques. The three code smells detected are the

lazy class, small method ad duplicate, while the refactoring approaches are the inline

class, inline method and extract clone respectively. Examples are presented for each

scenario to illustrate the methodologies. An evaluation of the refactoring was done

with an alogcat and arithmetic source code.

Page 31: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

9

Chapter 5 describes the working process of DART and the implementation of

the detection and algorithm rules in DART. Six (6) algorithms are presented to detect

and refactor lazy class, small method and duplicate code smells. These algorithms

have been extended in java code to design DART. Details about DART, installation

and process execution is attached in Appendix C. In the next chapter, an evaluation of

the developed tool based on alogcat application is discussed. The evaluation results is

also done in this chapter and a comparism before and after refactoring is presented.

Chapter 6 presents the user acceptability test results. Users were able to

explore the tool to detect, refactor and preview the smell. From the result, users have

a good feel of the tool, however, there is need to improve the refactoring process. A

comparism of DART and other tool is done, which shows the novelty of the DART tool

in detecting and refactoring lazy class and small method.

Finally, Chapter 7 concludes this research work and it presents the proposed

future work.

Page 32: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

CHAPTER 2

LITERATURE REVIEW

This chapter presents an overview on mobile application in Section 2.1. Section 2.2

gives an insight into android operating system. A general overview on software testing;

types and classification is discussed in Section 2.3. Section 2.4 discusses test cases and

the types of reduction techniques. A systematic literature review is presented in Section

2.5. Code smell and its detection techniques are discussed in Section 2.6, while the

refactoring techniques are discussed in Section 2.7. Refactoring tools are discussed in

Section 2.8. An overview on cyclomatic complexity is presented in Section 2.9, while

Section 2.10 summarizes the whole of Chapter 2.

2.1 Overview of Mobile Application

Mobile phones have been experiencing a high growth rate in technology development

[7]. Figure 2.1 shows the rate of growth in the mobile market. As the growth is

increasing so is the number of applications, since the inception of mobile app store

(for smart phones). The rising demand in the market for mobile applications has called

the attention of test engineers to the need to test mobile application as users are getting

more concerned on the quality and functionality of the software.

Page 33: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

11

Figure 2.1: The Growth Rate of Mobile Phones over the Years [1]

Source: http://www.aumcore.com/blog/2013/05/14/the-expected-growth-rate-of-adoptions-of-mobile-apps/

However, in the mobile market, Android remains the uppermost in demand.

Android was introduced by Google Inc. in October 2003. Android OS is an open

source software which gives other developers the opportunity to amend the program to

fit for their use. This open source feature has made android the choice of many users

and hence a rapid growth rate in market. Figure 2.2 shows the market place of smart

phones with android having the largest sales. The quality of applications working on

such a large market of OS becomes indispensable, thus making testing unavoidable.

Figure 2.2: The Android Market Growth [2]

Source: http://www.tech-thoughts.net/2013/08/smartphone-market-share-trends-by-country-q2-2013.html

Page 34: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

12

2.2 Android Operating System and Architecture

Android is an open source software that comprises the operating system (OS),

middleware, applications running locally, together with some application program

interface (API) programs for running the third party applications and the OS is based

on Linux [32][33]. Initially, it was primarily working on mobile devices such as

smartphones and tablets. Presently, Android OS is widely spread across various

embedded devices. It was formally built by Android Inc., which was founded in 2003

with their base in Palo Alto, California [34]. It initially functioned as subordinate to

Google but was later bought by Google in 2005. Android was officially revealed in

2007 and the first mobile phone running on Android OS was sold in October 2008

[35].

Android is open and easy to enhance and it is developed with several hardware

applications. The open source software and code was released under the license of

Apache. It is a full blown software, encompassing not only the operating system but

also the middleware and vital applications [32]. It remains one of the most commonly

used OS. Android has a great number of developers developing their own applications,

developed mainly on adapted Java Programming language. An android application can

be developed with a basic knowledge of Java programming [34]. Android OS versions

ranges from 1.0 Cupcake to 4.4 Marshmallow (28th May, 2015). It is noticeable that

all the OS versions are named after desserts, although the reasons Google adapts this

method remain unknown. The latest edition, which is the Marshmallow, was firstly

publicized at Google I/O on 28th May, 2015 and was announced as the Android M

developer preview. Several updates to the preview came out before Marshmallow was

officially named on 17th August, 2015. Google released Android 6.0 Marshmallow

together with the 2015 Nexus devices, on 29th September, 2015 [36].

Dalvik Virtual Machine (DVM) is a virtual machine that can be compared to

Java Virtual Machine (JVM) in terms of its functionality [37][38]. Google has picked

Java as the primary language for building Android application, but it has decided to

Page 35: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

13

drop both JME and the JVM in preference for a substitute deployment object, the

Dalvik virtual machine. The DVM works on bytecodes collected from the Java Class

files compiled by a Java compiler into a new class file format called the .dex format by

means of a dx tool that is contained within in the Android SDK (Software Development

Kit).The main objective of the DVM is designing of an unbiased platform for dex

files [39]. The developments of the DVM are stereotypically enhanced for the low

memory requirements required for development and execution of applications for the

mobile platform. It is developed to permit several VM instances to function at a time.

Also included in the Android application package are the API libraries for application

development containing SQLite, Webkit, OpenGL and a media manager. Inserted

within the API libraries is the Android runtime which comprises the Dalvik virtual

machine (DVM), for powering the applications [40]. It is also filled with basic built-in

applications including, messaging application, call log, picture viewer, web browser,

media player etc [32]. Figure 2.3 shows the Android architecture.

Figure 2.3: Android Architecture [48]

Page 36: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

14

Understanding the android architecture as it differs from the traditional java

program helps in implementing the case study used in this research.

2.3 Software Testing

Software testing is indispensable in order to ascertain the quality of software in

software development [41]. It is an essential aspect of the software engineering.

However, as important as it is, it costs lots of time and effort. It usually takes over 50%

of total development costs. Hence, there is an obvious need to reduce the cost while

improving the effectiveness of software testing [42]. One of the ways researchers have

tried to achieve this, is through automating the testing process [43][44][45]. Presently,

there are lots of software testing automation tools being developed and made available

in the marketplace [46][47][48].

However, testing can cover different areas such as specification, design and

implementation testing. Implementation testing which deals with the working system

of the software is most of the time referred to as software testing [49].

Having a flawless testing is not realistic, as it could take more than a life time to

complete even the simple software. The unrealistic nature of complete testing can be

explained by using a small program of a user filling a text field of 20 characters. This

program test will be complete by testing all possible input values. If an assumption

of 80 characters is made, then the number of possible combinations is 2080. Using a

computer that takes nanoseconds to process one combination, testing will take 1011

years to complete all possible combinations which is something very impossible and

unrealistic. Since it is impossible to guarantee 100% error free software, errors that are

not detected at the time of development before going to the end user may be discovered

and reported by the end user or in the process of testing for a subsequent release of the

software. Despite the imperfection of software testing, testers need to put their best

effort in improving the reliability and efficiency of the software as it can affect the

well-being of human and their safety [50].

Page 37: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

15

2.3.1 Classification of Software Testing

Software testing technique can be classified into three types : Black box, White box

and Grey box testing as shown in Table 2.1.

Table 2.1: Classification of Software Testing

Types of Testing Requirements FunctionalityBlack Box No prior knowledge of source code Entire system

White Box Prior knowledge of source code Source code

Grey Box Software Architecture and design documentation Test cases

• Black box testing Black box testing technique is carried out on running software

without having prior knowledge of its source code. Black box testing can also

be referred to as Functional Testing. The black box testing can involve the

functionality of the entire system or a unit of the system.

• White box testing This is carried out on running software when the code

structure and control flows are known to the tester [3]. The white box testing is

also known as Structural Testing. For white box testing, test cases are generated

based on the source code and software documentation which must be made

available to the testers.

• Grey box testing Grey box testing can be said to be a combination of both White

and Black Box Testing. In grey box testing, the software architecture and design

documentation should be made available to the tester. This gives an hint on the

inner working of the software and provides room for the design of better and

more fault-revealing test cases

2.3.2 Stages of Software Testing

While the technique used in this research is to be applied before the stages of testing,

however, since the focus is on testing, the stages of software testing is briefly discussed.

The stages in software testing as shown in Figure 2.4 are of five distinctive steps. The

Page 38: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

16

result at each level is used in the subsequent lower level. These levels as indicated

in Figure 2.4 include: Test case generation, Test case selection, Test case execution,

Report generation and Report analysis.

Figure 2.4: Stages in Software Testing

Test Case Generation

A test case, in software engineering, is a set of conditions or variables under

which a tester will determine whether an application, software system or one of its

features is working for the purpose it was originally established for. It can take many

test cases to confirm that a software program or system is considered sufficiently

scrutinized to be released. Test cases are often referred to as test scripts, particularly

when written - when they are collected they are referred to as test suites. Test cases can

also be defined as a set of inputs and expected output. These test cases are generated

to aid testing and the efficiency of test cases generated determine the quality of testing

as other stages are based on the test cases generated at this stage.

Page 39: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

17

Test Case Selection

For a program (or a function) that takes a finite set of input parameters, each

of which has a specified input domain, testing all combinations of parameter values

is referred to as exhaustive testing. The number of parameter combinations can be

very large, which makes exhaustive testing not applicable in most practical cases (as

explained in the previous section). One way to reduce the number of test cases in a

test suite, and still test all functionality in a specification, is by using partition testing.

In partition testing, the value domains are divided into equivalence classes, and the

tests are selected so that at least one value from each equivalence class is tested. Any

variable within a specified class domain can be chosen arbitrarily to represent other

members of the class.

Test Execution Environment

Software testing environments are applications that assist testers in executing

tests and collecting results against the application under test. Testing environments

are usually parallel with the applications they test. They run under the same operating

system and use the same programming language to interact with the SUT (Software

Under Test). This environment also provides services to support interfaces and libraries

for testing scripts. The cost of creating and supporting these testing environments is a

significant part of the overall development cost. The cost and complexity of the testing

environment increase when the software under test is distributed. Distributed software

may run in different host environments separated by a network. Different programming

languages may be used to code the different components in the software under test.

Report Generation

On a general note, a Report Generator is an application which purpose is to

take data from a source such as a database, XML stream or a spreadsheet and use it

to produce a document in a format which satisfies a particular human readership or

purpose. Report generation functionality is almost always present in database systems,

where the source of the data is the database itself. It can also be argued that report

generation is part of the purpose of a spreadsheet. Standalone report generators may

Page 40: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

18

work with multiple data sources and export reports to different document formats. A

good report is always the nicest thing to have to start a new project. It helps to reduce

repetitive work and gives an insight into the new job.

Report Analysis

Generating report might not be sufficient in giving details of testing. The

analysis of our report will show the validity of the software. In analyzing the result, a

test could either be pass or fail and more details will be given as to the reasons of these

test outcomes.

However, among a range of testing activities, test case generation is one of the

most intellectually demanding tasks and it is also of the most critical challenges, since

it can have a strong impact on the effectiveness and efficiency of the whole testing

process [51]. It is not surprising to know that a great number of researchers working

in test case reduction since the last decade. Hence, there are lots of techniques in this

area being studied and improved.

2.4 Types of Test Case Reduction Techniques

A test case is a set of conditions or variables that a software tester would consider

in determining whether an application, software system or one of its components is

functioning for the purpose it was developed [52]. Test case generation remain the

most important and challenging aspect of software testing [53] as the success of a

testing technique relies on the quality of the test cases generated [54]. According to

Leung and White [55] test cases can be classified to five categories. The first two

categories are newly generated test cases for a modified part P of a system while the

other three are in existence in the test suite T.

• New-structural: are test cases that are generated to test the modified program

structures. This type of test case provides structural coverage of the modified

parts P of the code.

• New-specification: This is based on the modified specifications of the system.

The test cases generated test the new code generated from the specifications of

Page 41: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

19

modified part P.

• Reusable: This class of test case executes the parts of the programs that are

common to two different programs. It is referred to as reusable as it can be used

to test subsequent versions of either program.

• Retestable: In this case, the test cases of part P of the program that have been

changed is tested. Hence, the test cases are re-executed to ensure that the changes

have not introduced a new bug.

• Obsolete: Test cases can be regarded as obsolete when they do not add values to

testing. This could be as a result of any of three conditions:

1. Changes in specification leading to incorrect input/output of the program

2. Modification of source code causing inability to test what it was testing

or

3. A structural test case that is not adding to the structural coverage of the

code

2.4.1 Test Case Minimization

Test suite minimization approaches aim at decreasing the magnitude of test cases by

removing unnecessary test cases from the test library [56]. Minimization is often

referred to as reduction, inferring that the eradication is permanent [57]. These two

words are usually used interchangeably. Formally, test suite minimization is defined as

follows [57]:

Let TS be a test suite, with a set of test specifications (s1..sn), that needs

to be fulfilled to run the anticipated testing of the SUT, and subclasses of TS say,

TS1, ..., TSn, with each of them being related to one another of the sis in such a way

that a test case tsj a member of TSi can be used to accomplish the specification in si .

The testing condition is fulfilled when all test specifications in (s1sn) are

fulfilled. A test specification, si , is fulfilled by any test case, ts(j) , that is a member

of TS(i) , a subclass of TS . Hence, the typical set of test cases is the set of the TSis.

Page 42: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

20

Moreover, to take full advantage of the result of minimization, TS ′ which is the least

typical set of TS should be the smallest set that can represent TSis.

To achieve the afore-stated definition, minimization of test case libraries

approaches tends to detect redundant test cases and eliminate them from the libraries so

as to lessen their sizes. The minimization challenge as defined above can be regarded

as the minimal representative set challenge. The formulation of this definition is based

on the assumption that each specification si can be fulfilled by a particular test case

tsi. In reality, this assumption may not hold water. For instance, if the test is based on

functional requirement with no relation to structural testing, therefore requiring more

than a test case to satisfy the specification, then it might not hold water. In this case, the

minimization definition requires some adjustment with a higher level of abstraction.

Various techniques have been proposed in minimizing the test suite [57]. Hsu

and Orso projected using an ILP solver with multi-criteria test suite minimization

[58] by likening several heuristics for a multi-criteria ILP formulation: the weightage

summation methodology, the ranked optimization and a crossbreed method. In ranked

optimization, the end user apportions a ranking value to all the specified conditions.

After optimizing for the initial condition, the outcome is added as a limitation, while

optimizing for the next condition and it continues like that. Nonetheless, one potential

weakness shared by these methods is that they necessitate extra involvement from

anyone using the approach in the form of weighting constants or ranking task, which

is likely to be biased, unobtainable or expensive to afford.

On the other hand, Yoo and Harman handled the challenge of time-aware

ranking as a multi-objective optimization issue [59]. Rather than applying a fitness

function that makes use of both selection and prioritization, they applied a Pareto-

efficient multi-objective evolutionary algorithm to concurrently optimize for several

objectives. Yoo and Harman [59] argued that the outcome of Pareto-frontier does not

only offer solutions but also permits the tester to notice trade-offs between objectives,

offering added perceptions. Bryce [60] also proposed a test suite minimization

technique based on call-stack coverage. In their approach, a test suite is symbolized

Page 43: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

21

by a group of distinctive maximum depth call stacks; its reduced test suite is a subclass

of the main test suite whose implementation produces the same group of distinctive

maximum depth call stacks. It is worth noting that this approach is different from

merely using function coverage for test suite minimization. For example, given two

sets of test cases, say T1 and T2 respectively, generating call stacks and s2, such that:

s1 = c1, c2, c3 and s2 = c1, c2

In terms of function coverage, c2 is rendered redundant by T1. However, Bryce

et.al. [60] regarded s2 to be distinct from s1. For instance, it could be that T2 identifies

a failure that stops the invocation of coverage c3. When the call-stack coverage data

is put together, the Harrold Gupta Soffa (HGS) heuristic can be used. They later used

the same method to test Graphical User Interface (GUI) [60]. It was also executed for

object-oriented testing by Smith et al. [61].

Leitner et al. considered the minimization challenge from another angle [62].

It all started with the assumption of having a too long, complex and failing set of test

cases for the software tester to comprehend. This is usually the norm with arbitrarily

generated test cases; the test case is most of the time just too complex for the tester

to find the root of failure. The aim of minimization is to generate a smaller form of

the test case; noting that the test case should still produce and depicts the same failure.

This minimization issue is quite motivating because there is no doubt about the fault-

detection competence; it is assumed to be a testing requirement. The efficiency of the

minimization technique can be calculated as follows [57]:

(1− NTCR

NTCO

)× 100 (2.1)

whereNTCR = Number of Test Cases in the Reduced Test Suite and

NTCO = Number of Test Cases in the Original Test Suite

The effect of test case minimization could be by calculating the decrease in

fault detection effectiveness as follows:

Page 44: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

22

(1− FDRTS

FTOTS

)× 100 (2.2)

whereFDRTS = Number of Faults Detected by the Reduced Test Suite and

FDOTS = Number of Faults Detected by the Original Test Suite

After sorting the test suites based on different levels of code coverage and

difficulty in identification of test cases, the following remark were made. Firstly, the

decrease in number of test cases was more obvious in higher code coverage in most

cases. This is expected as test suites with greater code coverage will need more test

cases on a general note. The mean reduction for test cases with 50 to 55%, 60 to

65 %, 70 to 75%, 80 to 85% and 90 to 95% code coverage were 1.19, 4.46, 7.78,

17.44, 44.23%, respectively. Secondly, the fault-detection effectiveness was decreased

by test case reduction, but the overall decrease in fault-detection effectiveness was

not excessive and could be regarded as worthwhile for the reduced cost. The average

effectiveness reduction for test suites with 50 to 55%, 60 to 65%, 70 to 75%, 80 to 85%

and 90 to 95% block coverage were 0, 0.03, 0.01, 0.38, 1.45%, respectively. Also, test

case reduction did not lessen the fault-detection capability for faults in Quartile-IV at

all. This implies that all failure in Quartile-IV had been identified by the minimized

test library. The average reduction in fault-detection capability for Quartile-I, II and

III were 0.39, 0.66, and 0.098%, respectively. Hence, WHLM study resolved that

if the cost of testing is proportional to the number of test cases, then the use of the

minimization technique is advised.

Wong et al. went further on the Wong, Horgan, London and Mathur (WHLM)

research by using the ATAC means for test suites of another, larger C platform;

this experimental study is sometimes referred to as the Wong, Horgan, London and

Pasquini (WHLP) study [63]. The researched software, space, is an interpreter for

the Array Description Language (ADL) built by the European Space Agency. In the

study, test cases were generated, not randomly, but from the functioning outlines of

space. This means that individual test case in the test case library has been generated

Page 45: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

23

to match a sample of actual function of space documented in a functioning outline.

From the test case library, various kinds of test cases were generated. A set of the

test cases was generated by randomly selecting a stable number of test cases from the

test case library. Another set of test cases was generated by selecting test cases from

the test case library until a code coverage that was known earlier is achieved. The

faults detected in the software were not false, but actual faults that were discovered

from building logs. The outcome of the Wong, Horgan, London and Pasquini (WHLP)

study established the conclusions of the WHLM study. As in the case of WHLM study,

test cases with small initial code coverage (50, 55, 60 and 65%) exhibited no reduction

in fault-detection capability, after reduction in the test library. Test case minimization

techniques show little or no effect on fault detection capability for both constant size

test case library and code coverage with an average drop of less than 7.28

Though the research on Wong, Horgan, London and Pasquini (WHLP) and

Wong, Horgan, London and Mathur (WHLM) depicts that reducing test cases has little

or no effect on fault detection effectiveness, other experimental studies show otherwise.

Rothermel et al. studied the effect of reducing the test case library on the fault detection

capability [64]. They used the HGS heuristics on the Siemens suite, and then extended

this by adding space. The outcome of this experimental study opposed the earlier

outcomes of the WHLM and WHMP studies. In using the Siemens suite, Rothermel

et al. generated test cases from the test case library given by the Siemens suite so

that the test cases comprise different quantities of redundant test cases that do not

add to the coverage result of the test suite. The efficiency and effect of reduction

were calculated using the same metrics that were applied in the WHLM research

work. Rothermel et al. stated that the application of the test suite reduction technique

resulted in noteworthy savings in the size of the library. The detected inclination in

test case minimization suggested a logarithmic association between the original test

case library and the effect of minimizing the test suite. The outcomes of logarithmic

regression established this. Nevertheless, Rothermel et al. stated that, as a result of

a decrease in size, the fault detection effectiveness of test suites has been rigorously

Page 46: UNIVERSITI TUN HUSSEIN ONN MALAYSIA - …eprints.uthm.edu.my/8744/1/Maryam_Temitayo_Ahmed_Thesis.pdf · UNIVERSITI TUN HUSSEIN ONN MALAYSIA STATUS CONFIRMATION FOR DOCTORAL THESIS

24

negotiated. The decrease in fault detection effectiveness was more than 50% for over

half of 1000 test cases studied, with some test cases attaining 100%. Rothermel

et al. also reported that, unlike the size reduction effectiveness, the fault detection

capability did not show any particular relationship with the size of the original test

suite. This initial empirical study was subsequently extended [64]. For the Siemens

suite, the results of the HGS heuristic were compared to those of random reduction by

measuring the fault detection effectiveness of randomly reduced test suites. Random

reduction was performed by randomly selecting from the original test suite, the same

number of test cases as in the reduced version of the test suite. The results showed that

random reduction produced larger decreases in fault detection capability. In summary,

the outcome of the Siemens suite experiment showed that the test suite minimization

technique reduces the size of the test suites while compromising the fault detection

capability; however, the reduction results showed improved fault detection efficiency

than the random minimization technique.

2.4.2 Test Case Prioritization

Test case prioritization deals with ordering test cases for early maximization of some

desirable properties, such as the rate of fault detection. It seeks to find the optimal

permutation of the order of test cases. It does not involve selection of test cases, and

it puts into consideration that all the test cases may be implemented in the order of

the permutation it produces, although the testing may be done at some inconsistent

stage during the testing process. More formally, the prioritization problem is defined

as follows:

Given: A test suite, TS , the set of permutations of TS , P, and a function from

P to real numbers, f : P→ r.