An Efficient Reduction Method for Test
Cases
Lilly Raamesh
ResearchScholar, Anna University, Chennai 25.
G.V. Uma
Asst. Professor/CSE, Anna University, Chennai-25.
Abstract:
Testing activity is performed to provide confidence that changes do not harm the existing behaviour of the software. Test suites tend to grow in size as software evolves, often making it too costly to execute entire test suites. The test suite reduction techniques significantly reduce the size of the test suites. But an important issue deals with how well these reduced suites can be compared with their corresponding un-reduced suites using other criteria rather than the suite size criterion. Since the purpose of test case execution is to detect faults in the software, one measure of the suite quality is its fault detection capability.
Keywords: Test case, Test Suite, Data Mining, Test Suite Reduction, Metrics, Clustering
1. Introduction
Software testing is a process of inspecting the performance of software. The objective of software testing is to detect faults in the program and therefore, provide more assurance for customers on the quality of the software. As a part of any software development process, software testing represents an opportunity to deliver quality software and to substantially reduce development cost.
Software regression testing is a significant activity to the development and maintenance of evolving software. A major difficulty with the regression testing is the excessive number of test cases accumulated while generating new test cases to test any new or modified functionality within the program. An effective technique for regression testing is to find a minimal subset of test cases which exercises all the test requirements as the original set does. A suitable subset could be found during the test case generation or after creating the test suite. Apparently the less the number of test cases the less time it takes to test the program. This consequently improves the effectiveness of the test process. The technique is commonly known as test suite reduction or test suite minimization in the literature and the resulting suite is called representative set.
2. System Design
The system consists of the following modules (1) Calculation & Selection of metrics (2) Clustering test cases
(3) Selection of test cases
2.1. Calculation & Selection of metrics (1) Lexical analyzer (2) Priority scheduler (3) Test case optimizer
2.1.1. Lexical analyzer
This module takes the given folder as input and analyses it to cluster the class files which is considered as test suite. Then, the clustered files are used in the next module to calculate the metrics.
2.1.2. Priority scheduler
Henderson-sellers
Brito
Lorenz
Chidamber
Henri
Properties
All the above metrics have their own default threshold values. After this calculation, based on the result corresponding metrics are selected in order to cluster the test cases. Based on the selected metric, the test cases are clustered and kept.
2.1.3. Test Case Optimizer
Heuristic method is applied for sampling test cases from clusters so long as the coverage of the reduced test suite equals to the coverage of the original suite. Initially, the heuristic sorts the clusters based on the number of test cases within each cluster ascending. In next step, the algorithm repeatedly considers the first cluster to the last one until the unmarked requirements are satisfied. In each iteration, a sample test case is selected from each cluster which forms the reduced test suite.
Fig 1. Overall system Design
2.2. Clustering Test Cases
2.2.1. Data Mining
Data mining, the extraction of hidden predictive information from large databases, is a powerful technology with great potential to help companies focus on the most important information in their data. Data mining techniques can be implemented rapidly on existing software and hardware platforms to enhance the value of existing information resources and can be integrated with new products and systems as they are brought on-line.
Data mining technology can generate new business opportunities by providing automated prediction of trends and behavior capability along with automated discovery of previously unknown patterns. Data mining techniques
Calculation of metrics
Selection of metric
Clustering test cases
Selection of sample
test cases from each
clusters
Test suite
are the result of a long process of research and product development. This evolution began when business data was first stored on computers, continued with improvements in data access, and more recently, generated technologies that allow users to navigate through their data in real time. Data mining takes this evolutionary process beyond retrospective data access and navigation to prospective and proactive information delivery, data mining is ready for application in the business community because it is supported by three technologies that are now sufficiently mature: Massive data collection, Powerful multi processor, Data mining algorithms.
2.2.2 Clustering
The process of dividing a dataset into mutually exclusive group such that the members of each group are as “close” as possible to one another, and different groups are as “far” as possible from one another, where distance is measured with respect to all available variables. Clustering is an unsupervised learning process: no predefined classes. Cluster analysis is finding similarities between data according to the characteristics found in the data and grouping similar data object into clusters.
A good clustering method will produce high quality clusters with high intra-class similarity and low inter-class similarity. The quality of a clustering result depends on both the similarity measure used by the method and its implementation. The quality of a clustering method is also measured by its implementation. The quality of a clustering method is also measured by its ability to discover some or all of the hidden patterns. There is a separate “quality” function that measured the “goodness” of a cluster.
2.3 Selection of Test Cases
2.3.1 Software Testing
Software testing is the process of executing a program in order to find faults, thus helping developers to improve the quality of the product when the discovered faults are solved and reducing the cost produced by these faults. A software test consists of a set of test cases, each of which is made up of the input of the program, called test data, and the output that must be obtained. As the target of software testing is to find faults, a test is successful if an error is found.
Testing is a very important, though expensive phase in software development and maintenance; a challenging part of this phase entails the generation of test cases. This generation is crucial to the success of the test, because it is impossible to achieve a fully tested program given that the number of test cases needed for fully testing a software program is infinite, and a suitable design of test cases will be able to detect a great number of faults. For these reasons, the techniques for automatic generation of test cases try to efficiently find a small set of cases that allow an adequacy criterion1 to be fulfilled, thus reducing the cost of software testing and resulting in more efficient testing of software products.
The search for an optimal solution in the test case generation problem has a great computational cost and for this reason these techniques try to obtain near optimal solutions. As a consequence, they have attracted growing interest from many researchers in recent years. On the other hand, the nature of software engineering problems is ideal for the application of Meta heuristic techniques.
2.3.2 Test Case
A test case is usually a single step, or occasionally a sequence of steps, to test the correct behavior/functionalities, features of an application. An expected result or expected outcome is usually given.
2.3.3 Test Suite
A test suite is a collection of test cases that are intended to be used to test a software program to show that it has some specified set of behaviors. A test suite often contains detailed instructions or goals for each collection of test cases and information on the system configuration to be used during testing. A group of test cases may also contain prerequisite states or steps, and descriptions of the tests.
2.3.4 Test Suite Reduction
Test suite reduction techniques try to remove redundant test cases of a test suite. The test suite minimization problemcan be formally stated as follows. Given:
(2) A set of testing requirements {r1, r2, r3,. . ., rn} that must be satisfied to provide the desired testing coverage of the program.
(3) Subsets {T1, T2, T3,. . ., Tn} of T, one associated with each of the ri’s, such that any one of the test cases tjs belonging to Ti satisfies ri.
There are many techniques available for test suite reduction that have their own advantages and disadvantages.
A potential drawback of existing minimization approaches is that they may significantly decrease the fault detecting capability. This is because, these techniques
• Permanently discards some of the test cases of the test suite.
• It may cause high decrease in fault detection effectiveness of the reduced suite.
Thus, the Trade off between the times required to execute and manage test suites and their fault detection effectiveness should be considered when applying test suite reduction techniques
The algorithm clusters test cases based on the similarity of their execution profiles and samples some representatives toform the reduced test suite.
3. Source Code
//MainWindow.java import java.util.*; import java.awt.*; import java.awt.event.*; import javax.swing.*;
class MainWindow extends JFrame implements ActionListener { private JButton btyap;
private JButton btbrito; private JButton btkid; private JButton btchi; private JButton bthenri; private JButton btprop; private JButton btexit; private JList lstclass; private JLabel lblclass; private JScrollPane jsp; private JLabel lblproj; private JTextField txtproj; private JButton btproj; private JLabel lbltitle; private Font font; private JPanel panel; MainWindow() { super("testsuit");
panel = (JPanel) getContentPane(); panel.setLayout(null);
ic = new ImageIcon("title.gif"); lbltitle = new JLabel(ic);
lbltitle.setSize(ic.getIconWidth(),ic.getIconHeight()); lbltitle.setLocation(15,30);
lbltitle.setVisible(true); panel.add(lbltitle);
font = new Font("MS Sans Serif",Font.PLAIN,14); lblproj = new JLabel("CASE Name");
lblproj.setFont(font); lblproj.setSize(90,25); lblproj.setLocation(30,100); lblproj.setVisible(true); panel.add(lblproj); txtproj = new JTextField(); txtproj.setFont(font); txtproj.setEditable(false); txtproj.setSize(270,25); txtproj.setLocation(130,100); txtproj.setVisible(true); panel.add(txtproj);
}} if (ae.getSource() == bthenri)
if (tcname == null)
{ Screen.showMessage("Select a Class Name"); return; }
cprop = getCPObject(tcname); henrianal = new HenriAnalysis();
henrianal.setNSendStat(cprop.getHenriValues(1)); henrianal.setNADTs(cprop.getHenriValues(2)); henrianal.setNLocalMethods(cprop.getHenriValues(3)); henrianal.setNSemicolons(cprop.getHenriValues(4)); henrianal.setNProperties(cprop.getHenriValues(5)); val = henrianal.getResults();
result = new AnalysisResult(this); result.setTitle("Li & Henri Metric"); result.setValue(val);
result.showGrid(); } if (ae.getSource() == btproj) { fc = new FileChooser();
String fname = fc.getFileName().trim(); if (fname.length() == 0) return; txtproj.setText(fname);
clist = new ClassList(txtproj.getText()); cname = clist.getClassNames(); lstclass.setListData(cname); if (cname.length == 0)
{ Screen.showMessage("No Class File Found"); txtproj.setText("");
return; }
childcount = new ChildCount(cname); childcount.getChildCount();
chcount = childcount.getChildList(); subcount = childcount.getSubclassCount(); supcount = childcount.getSuperClassCount(); clcount = cname.length;
cpvect = new Vector();
overall = new Object[cname.length][14]; for(int i=0;i<cname.length;i++)
{ tcname = cname[i].substring(0,cname[i].indexOf('.')); cprop = new ClassProperties(tcname,this);
cpvect.add(cprop.getClassProperties()); overall[i][0] = String.valueOf((i+1)); overall[i][1] = cprop.getClassName();
overall[i][2] = String.valueOf(cprop.getPrivateFields()); overall[i][3] = String.valueOf(cprop.getPublicFields()); overall[i][4] = String.valueOf(cprop.getProtectedFields()); overall[i][5] = String.valueOf(cprop.getFriendlyFields()); overall[i][6] = String.valueOf(cprop.getFieldCount()); overall[i][7] = String.valueOf(cprop.getPrivateMethods()); overall[i][8] = String.valueOf(cprop.getPublicMethods()); overall[i][9] = String.valueOf(cprop.getProtectedMethods()); overall[i][10] = String.valueOf(cprop.getFriendlyMethods()); overall[i][11] = String.valueOf(cprop.getMethodCount()); overall[i][12] = String.valueOf(cprop.getChildLevel()); overall[i][13] = String.valueOf(cprop.getSubLevel()); } flag = true;
} if (ae.getSource() == btprop) { if (flag == false)
{ Screen.showMessage("Select the Project"); return; }
proper = new Properties(this); proper.setValue(overall); proper.showGrid(); } if (ae.getSource() == btexit) System.exit(0); }
public ClassProperties getCPObject(String tcname) { ClassProperties tcp;
String temp;
tcname = tcname.substring(0,tcname.indexOf('.')); for(int i=0;i<cpvect.size();i++)
if (tcname.equals(temp)) return tcp; } return null; }
public static void main(String args[]) { new MainWindow(); }}
4. Conclusion and Future Work
This algorithm reduced the number of test cases generated which results in manageable size test suit so that the test suit can be run many times as software is modified and evolved.
There are threats to external validity. Thus, in future variety of different real world problems has to be exercised in order to generalise the technique.
5. References
[1] Jun-Wei Lin and Chin-Yu Huang, “Analysis of test suite reduction with enhanced tie-breaking techniques”, 2008. [2] Hao Zhong, Lu Zhang and Hong Mei, “An experimental study of four typical test suite reduction techniques”, 2006. [3] Preeyavis Pringsulaka and Jirapun Daengdej, “Cover all Algorithm for Test Case Reduction”, 2006.
[4] Xue-ying MA, Bin-kui SHENG, Zhen-feng HE and Cheng-qing YE,”A Genetic Algorithm for Test-Suite Reduction”, 2008.
[5] Zhi Quan, Bernhard and Gioranni, “Automated Software Testing and Analysis: Techniques, Practices and Tools”, Proc. of Intl Conf. on System Sciences, HICSS’07, 2007, pp 260.
[6] Emanuela G, Franciso and Patricia,” Test Case Generation by means of UML sequence diagrams and Labeled Transition Systems,” IEEE, 2007,pp.1292-1297.
[7] Belal and Essam, “The constraints of Object-Oriented Databases”, Internation Journal of Open Problems in Computer Science and Mathematics, 2008, Vol.1, No.1,pp. 11-17.
[8] Shaukat Alia, , Lionel C. Briandb, Muhammad Jaffar-ur Rehmana, Hajra Asghara, , Muhammad Zohaib Z. Iqbala, and Aamer Nadeema, “A statebased approach to integration testing based on UML models”, Elsevier, Vol. 49, Issue 11 and 12, 2007, pp. 1087-1106.
[9] Marlon Vieira, Johanne Leduc, Bill Hasling, Rajesh Subramanyan and Juergen Kazmeier, “Automation of GUI testing using a model-driven approach”, Proceedings of International workshop on Automation of Software Test, 2006, pp. 9-14.
[10] Aynur Abdurazik, Jeff Offutt and Andrea Baldini, “A Controlled Experimental Evaluation of Test Cases Generated from UML Diagrams”, Technical report, George Mason University, ISE-TR-04-03, 2004.
[11] Wang Linzhan, Yuan Jieson, Yu, Hu, LI and Zheng, “Generating Test cases from UML activity diagram based on Graybox method”, APSEC, IEEE, 2004, pp.284-291.