TestcaseReduction DataMiningTechnique
TestcaseReduction DataMiningTechnique
net/publication/308767854
CITATIONS READS
13 879
4 authors:
Some of the authors of this publication are also working on these related projects:
Source code-based defect prediction using deep learning and transfer learnin View project
All content following this page was uploaded by Ahmad A. Saifan on 20 February 2017.
ABSTRACT
Software testing is a process of ratifying the functionality of software. It is a crucial area which
consumes a great deal of time and cost. The time spent on testing is mainly concerned with testing
large numbers of unreliable test cases. Our goal is to reduce the numbers and offer more reliable test
cases, which can be achieved using certain selection techniques to choose a subset of existing test
cases. The main goal of test case selection is to identify a subset of the test cases that are capable of
satisfying the requirements as well as exposing most of the existing faults. The state of practice
among test case selection heuristics is cyclomatic complexity and code coverage. We used
clustering algorithm which is a data mining approach to reduce the number of test cases. Our
approach was able to obtain 93 unique effective test cases out a total of 504.
Keywords: test case reduction, clustering, cyclomatic complexity, coverage, redundant test cases.
1. INTRODUCTION
Software quality is an important issue that all developers of software systems want to achieve. It
currently attracts a lot of attention since software is everywhere and affects our lives on a daily
basis. Software testing is the main factor in enhancing and increasing the quality of software, for
which it is necessary to generate different test cases according to certain coverage criteria such as
graph, logic, input space, and syntax coverage (Amman & Offut, 2008). The size and complexity
of software systems is growing dramatically, in addition to which, the existence of automated tools
leads to the generation of a huge number of test cases, the execution of which causes huge losses in
cost and time (Lilly & Uma, 2010). According to Rothermel et al. (Rothermel et al., 2001), a
product of about 20,000 lines of code requires seven weeks to run all its test cases. Ultimately, the
challenge is to find a way to reduce the number of test cases or to order the test cases to validate the
system being tested.
The main goal of software testing is ensure that the software is almost free from errors. The test
process can be said to be effective when the test cases are able to locate any errors. Several tools
have been seen in the literature which automatically generate thousands of test cases for a simple
program in a few seconds, but executing those test cases takes a great deal of time. Moreover, the
tools could also generates redundant test cases (Muthyala et al., 2011). The problem is compounded
when we have complex systems, where the execution of the test cases may take several days to
complete. Moreover, it should be noted that most of the time is spent in executing redundant or
unnecessary test cases.
To identify the redundant test cases a technique such as data mining (Lilly & Uma, 2010) is
required to understand the properties of test cases, with a view to determining the similarities
between them and removing the redundant ones.
1
This paper aims to deal with this issue, of reducing the number of test cases in order to minimise the
time and cost of executing them. Several techniques can be used to reduce test cases such as
information retrieval, pairwise testing (Yoo at al., 2009) and data mining. We used the data mining
approach, mainly because of the ability of data mining to extract patterns of test cases that are
invisible.
We present our approach, concentrating on the two most effective attributes of test cases, coverage
and complexity (Kameswari et al., 2011). An empirical study presented in (Jeffery & Gupta, 2007)
suggested that during test case reduction, using several coverage criteria rather than single coverage
is more effective in selecting test cases that are able to expose different faults.
We start by collecting the test cases for a given system and then we build the dataset by selecting
coverage and complexity. Next, we use data mining technique, K-clustering, to group several test
cases into a particular cluster. Finally, redundant test cases that have the same distance to the cluster
centre point are removed. To evaluate our approach we calculate the coverage ratio of the original
test cases and compare it with the coverage ratio of the reduced test cases.
A set of test cases is defined to test program traces including instructions, methods and branches.
The set of test cases is defined as T = {t , t , … , t ∝ }, where t = {a , a , … , a } is a test case defined
to cover one of the following:
In order to reduce the number of generated test cases according to their coverage, K-MEANS
clustering is applied using Euclidian distance that measure the distance between any given test case
and the centroid. Specifically, the set of test cases is divided into k − centroids where the distance
between every test case and its related centroid is computed.
A test cases t is considered redundant with t if dist(t , centroid) = dist(t , centroid), in which
t , t belong to the same centroid. In this case, pick the test case with Min Cyclomatic t , t .
2.2 COMPARISON
2
Lots of research in the literature investigated the enhancement of software testing through reduction
of test cases using the clustering data mining techniques. The goal for all these techniques is to
remove the redundant test cases and keep reliable and effective ones.
(Muthyala et al., 2011; Kameswari et al., 2011; Dash ey al., 2012 ) proposed a model that has the
same procedure in reducing the test cases using k-means algorithm based on path coverage. In
(Chantrapornchai et al., 2014) they used the branch coverage. The model starts by identifying a
centroid for each cluster. Then, they take each test case and associate it to the nearest centroid. After
that, they recalculate the new centroid for each cluster. However, they verified their approach using
a simple system that contains two variables. It means it will be so hard to apply this technique with
more complex systems. Moreover, in their approach they identify the number of clusters in advance
(i.e. before the reduction process started) based on the prime paths generated from the code. In
contrast, our approach work in different way. At the beginning we compute test suite coverage and
cyclomatic complexity. Then, we apply k-means clustering on these test suite based on distance
between cluster centroid and test cases. For those test cases that have the same distance we call it
redundant test cases. So from those redundant test cases we pick up the test case that has the lowest
cyclomatic complexity. Moreover, we used a real test cases for a system that is more complex than
the systems used in the previous works; e.g. system that has only two variable.
Another approach presented in (Chantrapornchai et al., 2014), an approach that is used to reduced
the number of test cases using k-mean clustering algorithm based on branch coverage. The
approach has the same approach discussed in (Muthyala et al., 2011; Kameswari et al., 2011; Dash
ey al., 2012 ). They apply their approach on a very simple system which is "valued added tax for
liquor chilled". They were able to reduce the number of test cases from 648 to 324 with almost the
same code coverage before and after the reduction process.
(Carslon et al., 2011) proposed a clustering approach that is used to prioritize the test cases based on
three different information which are: code coverage (method coverage), complexity and history
data on real fault. The main purpose of their approach is to show how clustering approach can
improve the rate of fault detection of test cases. Their technique utilize clustering in test case
prioritization but the primary difference between their approach and our approach is that they only
use method coverage for clustering . In contrast, our approach applies test cases reduction based on
branch coverage, path coverage and method coverage.
3. RELATED WORK
The first formal definition of test suite reduction problem was introduced in 1993 by Harrold et al.
(Harrold et al., 1993) as follows: Given. {t1, t2,...,tm} is test suite T from m test cases and {r1,
r2,...,rn} is a set of test requirements that must be satisfied in order to provide desirable coverage of
the program entities and each subset {T1, T2,...,Tn} from T are related to one of ris such that each
test case tj belonging to Ti satisfies ri. Problem. Find minimal test suite T' from T which satisfies all
ris covered by original suite T.
In general, there are two types of test case reduction technique, pre-process and post-process
(Roongruangsuwan & Daengdej, 2010). The pre-process technique reduces the test cases before the
execution of test cases and immediately after their generation. The post-process technique reduces
the number of test cases after the test is run.
Several techniques have been proposed in the literature, including heuristic algorithms (Dickinson
et al., 2001), genetic algorithm based approach (Mansour & El-Fakih, 1999), integer linear
3
programming approach (Black et al., 2004), and hybrid approach (Yoo & Harman, 2010). A survey
proposed in (Yoo & Harman, 2010) summarizes these techniques.
A great deal of work has been carried out in the area of test suite reduction; however this has mainly
been in the area of automated software testing to avoid manual testing through the generation of test
cases from UML diagrams such as state machine diagrams, use case diagrams, sequence diagrams,
etc. (Lilly & Uma, 2010; Sharma & Sharma, 2011; Sawant & Shah, 2011; Heumann, 2001).
Other researchers have worked in the test case reduction field to improve systems testing processes,
such as regression testing (Pravin & Srinivasan, 2013). In order to find a more efficient algorithm
for reducing test cases, they have presented an approach that assigns priority for each test case.
Priority is given depending upon the code coverage, and higher priority test case value is selected
for the reduced test suites. To demonstrate the effectiveness of their algorithm, the approach is
applied to two applications.
(Maung & Win, 2015) proposed the entropy based test case reduction approach to reduce test suite
size for website testing. The higher entropy value leads to the more URLs being covered. They
calculate the entropy value based on dependent pages of structural analysis. The total number of
links is chosen as the base algorithm to normalize the entropy value to the range zero to one. The
maximum entropy value of the user that covers all or most URLs is selected as a test case.
(Roongruangsuwan & Daengdej, 2010) used the Artificial Intelligence based algorithm, Case-
Based Reasoning (CBR), for test case reduction. This algorithm was used to find the most similar
test cases from the case storage and remove the redundant test cases using the CBR deletion
algorithms. The CBR stored the test cases it found in a storage in order to learn from their
experience. They proposed three reduction methods that are applied in the CBR deletion algorithms:
Test Case Complexity for Filtering (TCCF), Test Case Impact for Filtering (TCIF) and Path
Coverage for Filtering (PCF) methods. Those techniques aim to reduce the number of test cases
generated by path-oriented test case generation technique.
(Kartheek Muthyala et al., 2011) proposed a new approach to reduce the number of test cases using
data mining techniques. They used both Simple K-means and pickupCluster clustering algorithm in
order to reduce the number of test cases. (Saifan, 2016) produced an approach that use data mining
classifier techniques in order to reduce the test cases.
An approach that is similar to our approach that have been discussed by (Subashini & JeyaMala,
2014). In their approach they used the path coverage criterion in order to generate a set of test cases.
Then, they proposed a clustering technique to reduce the number of test cases using very simple
programs based on the path coverage criterion only. However, in our work we use the coverage
criteria and complexity in the clustering technique.
(Rashi et al., 2014) proposed a new approach for test suite reduction using density based clustering
technique. They started by generating a set of test cases using Selenium tool, before loading the test
cases in Weka and applying DBSCAN clustering algorithm to them. Finally, an appropriate filter
was used to remove redundant test cases. In this paper we use knowledge mining techniques,
specifically K-means clustering algorithm, in order to reduce the number of test cases and choose
those which are most effective for fault detection.
4
1. Collect a set of test cases from a given Java source code
2. Extract the complexity and the coverage for each test case to build the dataset
3. Apply K-mean clustering method to the dataset
4. Eliminate the redundant test cases using distance from the centre point
5. Analyse the results
Figure 1 shows the steps of our approach and the tools used to perform each step. We will now
describe each of these steps in detail.
4.1 PHASE 1: COLLECT A SET OF TEST CASES FROM A GIVEN JAVA SOURCE
CODE
Our approach starts with selecting the source code. In this paper, we select a Java source called
"Cinema". Table 1 shows some of the properties of the source code such as the system classes, lines
of code, and the number of methods in each class. In order to run the system we use eclipse SDK
3.7.2 software (Eclipse, 2016) which is an integrated development environment (IDE). It contains a
base workspace and an extensible plug-in system for customizing the environment written mostly in
Java programming language.
Next we select a set of test cases for the given system. Our test cases come from different sources,
with some being manually generated and others automatically generated using CodeproAnalytix
tool (CodePro, 2016). CodeProAnalytix is an automated software quality and testing tool for
5
Eclipse developers, which contains many key features such as error detection, static code analysis,
code metrics, and test generation. In this paper we use one of the most important key features of this
tool which is test case generation using JUnit. The tool is used to automatically generate a set of test
cases for any given input class.
After manually generating and applying the tool we obtained 21 test suites with a different number
of test cases in each. Table 2 shows the test suites with a specific number of test cases for each one
with a total of 504 test cases.
4.2 PHASE 2: EXTRACT THE COMPLEXITY AND THE COVERAGE FOR EACH TEST
CASE TO BUILD THE DATASET
The second step is the most important in our approach because it is the framework for the following
phases, so it will be complex and contain sub-phases. In order to build the dataset we need to select
the most important and effective attributes for the test cases. Based on the literature (Mondal et al.
2015; Upadhyay & Misra, 2012; Elbaum et al., 2002) we noticed that the average cyclomatic
complexity and the code coverage are the most two effective attributes in test case selection, so our
dataset will contain the complexity and the coverage for each test case. Firstly, we use
CodeProAnalytix tool (CodePro, 2016) to compute the average cyclomatic complexity per method
in the system which is a measure of the number of distinct paths of execution within the method.
This is measured by adding one path for the method with each of the paths created by conditional
statements (such as “if” and “for”) and operator (such as ? ). After that we need to compute the
coverage for each test case. Code coverage is one of the metrics which measure the efficiency of
the testing process, and an important quality indicator for effectiveness of the test cases. It measures
how the test cases cover all codes. In this paper we use Eclemma (Eclemma, 2016)[19], which is a
software testing tool for Eclipse, to compute the code coverage. It automatically generates code
6
coverage reports for the test cases and supports the following four different types of code coverage
(Eclemma, 2016) :
Due to space limitation we only show the average cyclomatic complexity and the code coverage for
test suite "CineTest" (see Table 3).
As we can see from Table 3, the cyclomatic complexity and the code coverage for this test suite is
very high, which means that these test cases are very effective in detecting any errors in the system.
From the above two quality metrics we build the data set which consists of five attributes
(complexity, covered branches, covered lines, covered methods and covered instructions) with a
total of 504 test cases. Table 4 shows a sample of our dataset with the values of complexity and
coverage for each test case.
7
Let db = {db , db , … , db } be the set of data points and C = {c , c , … , c } be the set of
centres.
1. Randomly select c cluster centres.
2. Calculate the distance between each data point db and cluster centers.
3. Assign the data point to the cluster centre whose distance from the cluster centre is minimum
of all the cluster centres.
4. Recalculate the new cluster centre using:
= (1 ⁄ndb ) db
8
In this paper we use the Statistical Package for Social Sciences (SPSS) (SPSS, 2016) in order to
carry out the clustering process using K-mean algorithm. SPSS is used by market researchers,
health researchers, survey companies, marketing organizations, data miners and others.
Based on the number of test cases that we have in our system we decided on three clusters (K) and
we chose the default number of iteration which is ten. According to the values of all the attributes
we chose the attribute “Line” as a class for our dataset which indicates the number of covered lines
of code by a test case, because of the diversity of its values. Table 5 represents the final number of
test cases for each cluster point after applying K-mean clustering algorithm.
9
For example, test cases 8,9,10,11,12,13, and 14 in Table 6 are grouped around cluster one and are at
the same distance from the centre point. In this case we would choose one of them and remove the
rest because they are redundant test cases.
As a result of the process of removing the redundant test cases we obtained 93 unique effective test
cases out of a total of 504 test cases. This means that the test cases at the same distance from their
cluster’s centre point are not important and testing them would be inefficient. Table 7 shows the
number of unique test cases for each cluster after applying the removing process.
Figures 3 and 4 represent the distance for each test case before and after removing the redundant
test cases from the three clusters respectively.
10
Figure 4. Test case visualization after the reduction.
From Table 8 we note that the coverage still yielded good results. In other words, the code coverage
decreased by an acceptable different percentage for each type of coverage. However, the percentage
of branch coverage decreased by 4.4%. (Zhang et al., 2014) mentioned in their paper that by using
different approaches of test case reduction the branch coverage is increased after reducing test
cases. Moreover, (Sampath et al., 2005) mentioned that when the attribute values vary then the
coverage will increase. This is what we observed after checking the branch attribute values. Before
the reduction process there were a lot of zeros compared to the other values (50, 17, 94) of branch
attribute. After the reduction process almost all of the zeros values were omitted, thus the values of
this attribute become more varied than before the reduction process.
11
5. CONCLUSIONS AND FUTURE WORK
We have demonstrated the methodology for the test case reduction using data mining clustering
algorithm. Firstly test cases were collected. Then, we computed average cyclomatic complexity and
code coverage for each test case in order to select the most effective test cases to build our data set.
After that, we applied K-mean clustering algorithm with three clusters to our data set. Finally
redundant test cases with the same distance from their cluster centres were removed. We tested our
reduced test suite for coverage and noted that the removed test cases are not important in software
testing. In this paper we used small program with small number of test cases. In the future we will
check the effectiveness and the efficiency of our approach using large project based on the ability of
the revealing faults in the software under test. Furthermore, new important feature of the test cases
which is the quality of the test case will be also considered as a parameter in the data set for the
future work.
References
Muthyala, K., & Naidu, R. (2011). A novel approach to test suite reduction using data
mining. Indian Journal of Computer Science and Engineering, 2(3), 500-505.
Raamesh, L., & Uma, G. V. (2009). Knowledge Mining of Test Case System. International Journal
on Computer Science and Engineering 2(1), 69-73.
Yoo, S., Harman, M., Tonella, P., & Susi, A. (2009, July). Clustering test cases to achieve effective
and scalable prioritisation incorporating expert knowledge. In Proceedings of the eighteenth
international symposium on Software testing and analysis (pp. 201-212). ACM.
Raamesh, L., & Uma, G. V. (2010). Reliable Mining of Automatically Generated Test Cases from
Software Requirements Specification (SRS). International Journal of Computer Science
(IJCSI). arXiv preprint arXiv:1002.1199. 7(1).
Raamesh, L., & Uma, G. V. (2010). An efficient reduction method for test cases. International
Journal of Engineering Science and Technology, 2(11).
Roongruangsuwan, S., & Daengdej, J. (2010). Test Case Reduction Methods by Using CBR.
In International Workshop on Design, Evaluation and Refinement of Intelligent Systems
(DERIS2010) (p. 75).
Sharma, S., & Sharma, A. (2011). Amalgamation of Automated Testing and Data Mining: A Novel
Approach in Software Testing. International Journal of Computer Science (IJCSI), 8(5).
Sawant, V., & Shah, K. (2011). Automatic Generation of Test Cases from UML Models.
In International Conference on Technology Systems and Management (ICTSM), Proceedings
published by International Journal of Computer Applications (IJCA).
12
Heumann, J. (2001). Generating test cases from use cases. The rational edge,6(01).
Pravin, A., & Srinivasan, D. S. (2013). An Efficient Algorithm for reducing the test cases which is
used for performing regression testing. In 2nd International Conference on Computational
Techniques and Artificial Intelligence, Dubai (UAE) (pp. 194-197).
Maung, H. M., & Win, K. (2015). An efficient test cases reduction approach in user session based
testing. International Journal of Information and Education Technology, 5(10), 768.
Bouckaert, R. R., Frank, E., Hall, M., Kirkby, R., Reutemann, P., Seewald, A., & Scuse, D. (2015).
WEKA manual for version 3-7-12.
Chauhan, R., Batra, P., & Chaudhary, S. (2014). An Efficient Approach for Test Suite Reduction
using Density based Clustering Technique. International Journal of Computer Applications, 97(11).
Eclipse Classic 3.6.2 (2016), retrieved April 17, 2016, from https://eclipse.org.
Saifan, A.(2016). Test case reduction using data mining classifier techniques. The 2nd International
conference in Computer and Information Technology (ICCIT). Istanbul, Turkey.
Mondal, D., Hemmati, H., & Durocher, S. (2015, April). Exploring test suite diversification and
code coverage in multi-objective test case selection. InSoftware Testing, Verification and Validation
(ICST), 2015 IEEE 8th International Conference on (pp. 1-10). IEEE.
Upadhyay, A. K., & Misra, A. K. (2012). Prioritizing Test Suites Using Clustering Approach in
Software Testing. International Journal of Soft Computing and Engineering (IJSCE), 2(4).
Elbaum, S., Malishevsky, A. G., & Rothermel, G. (2002). Test case prioritization: A family of
empirical studies. Software Engineering, IEEE Transactions on, 28(2), 159-182.
Java Code Coverage for Eclipse. retrieved April 17, 2016, from
http://www.eclemma.org/index.html.
Witten, I. H., & Frank, E. (2005). Data Mining: Practical machine learning tools and techniques.
Morgan Kaufmann.
SPSS Statistics Base 17.0 User’s Guide. retrieved April 17, 2016, from
http://www.jou.ufl.edu/archive/researchlab/SPSS-Statistcs-Base-Users-Guide-17.0.pdf.
Sampath, S., Sprenkle, S., Gibson, E., Pollock, L., & Souter, A. (2005, May). Analyzing clusters of
web application user sessions. In ACM SIGSOFT Software Engineering Notes (Vol. 30, No. 4, pp.
1-7).
Kameswari, U. J., Saikiran, A., Reddy, K. V. K., & Varun, N. Novel Techniques For Test Suite
Reduction. International Journal of Science and Advanced Technology, 1(8).
13
Subashini, B. & and JeyaMala, D. (2014). Reduction of Test Cases Using Clustering Technique.
In Proceedings of International Conference on Innovations in Engineering and Technology
(ICIET’14).
Jeffrey, D., & Gupta, N. (2007). Improving fault detection capability by selectively retaining test
cases during test suite reduction. IEEE Transactions on Software Engineering, 33(2), 108-123.
Harrold, M. J., Gupta, R., & Soffa, M. L. (1993). A methodology for controlling the size of a test
suite. ACM Transactions on Software Engineering and Methodology (TOSEM), 2(3), 270-285.
Dickinson, W., Leon, D., & Podgurski, A. (2001, September). Pursuing failure: the distribution of
program failures in a profile space. In ACM SIGSOFT Software Engineering Notes (Vol. 26, No. 5,
pp. 246-255). ACM.
Mansour, N., & El-Fakih, K. (1999). Simulated annealing and genetic algorithms for optimal
regression testing. Journal of Software Maintenance,11(1), 19-34.
Black, J., Melachrinoudis, E., & Kaeli, D. (2004, May). Bi-criteria models for all-uses test suite
reduction. In Proceedings of the 26th International Conference on Software Engineering (pp. 106-
115). IEEE Computer Society.
Yoo, S., & Harman, M. (2010). Using hybrid algorithm for pareto efficient multi-objective test suite
minimisation. Journal of Systems and Software, 83(4), 689-701.
Singh, R., & Santosh, M. (2013, December). Test Case Minimization Techniques: A Review.
In International Journal of Engineering Research and Technology (Vol. 2, No. 12 (December-
2013)). ESRSA Publications.
Zhang, C., Groce, A., & Alipour, M. A. (2014, July). Using test case reduction and prioritization to
improve symbolic execution. In Proceedings of the 2014 International Symposium on Software
Testing and Analysis (pp. 160-170). ACM.
Ammann, P., & Offutt, J. (2008). Introduction to software testing. Cambridge University Press.
Rothermel, G., Untch, R. H., Chu, C., & Harrold, M. J. (2001). Prioritizing test cases for regression
testing. Software Engineering, IEEE Transactions on,27(10), 929-948.
Dash, R., & & Dash, R. (2012). Application of K-mean Algorithm in Software Maintenance.
International Journal of Emerging Technology and Advanced Engineering,Vol. 2(5).
Carlson, R., Do, H., & Denton, A. (2011, September). A clustering approach to improving test case
prioritization: An industrial case study. In Software Maintenance (ICSM), 2011 27th IEEE
International Conference on (pp. 382-391). IEEE.
Chantrapornchai, C., Kinputtan, K., & Santibowanwing, A. (2014). Test Case Reduction Case
Study for White Box Testing and Black Box Testing using Data Mining. International Journal of
Software Engineering and Its Applications, 8(6), 319-338.
14
15