3rd IEEE International Conference on "Computational Intelligence and Communication Technology" (IEEE-CICT 2017)
Generation of Automatic Test Cases with Mutation Analysis and Hybrid Genetic Algorithm Rijwan Khan
Mohd Amjad
Akhilesh Kumar Srivastava
Department of Computer Engineering Jamia Millia Islamia- New Delhi
[email protected]
Department of Computer Engineering Jamia Millia Islamia- New Delhi
[email protected]
Department of Computer Engineering ABES Engineering College- Ghaziabad
[email protected]
important phase of SDLC. Two most important testing namely path testing and mutation testing are used in this paper. In path testing all du-paths are found, with each variable of program/software defined, c-use and p-use are found. In path testing, all the paths of program are found. During the Testing process it is also found that how much paths are covered. In other way mutation testing is a process of injecting mutants in a program/software and find these mutants during testing process. In this paper mutation testing has been used with path testing [8, 12].
Abstract—Software testing is one of the most important and expensive (in term of time and cost) phase of software development life cycle. Over the past few decades a lot of research has been done on automatic software testing process but due to dynamic memory allocation, software is very much unpredictable in behavior. Different Meta heuristic algorithms are applied for improving the efficiency of software testing process. Mutation testing is a one kind of the software testing in which some mutants are injected intently in the program/software and tester finds these mutants during testing process [4]. In this paper a Hybrid Genetic Algorithm is proposed for generating test data automatically using data flow testing approach for mutation testing.
III.
A tool has been designed in C# which automatically generate a CFG for a given C Program.
Keywords—software testing; Hybrid Genetic Algorithm(HGA); Genetic Algorithm; testing efficiency; automatic test case generation
I.
TOOL FOR GENERATING CFG AUTOMATICALLY
e. g. A C program for generating primary number between two intervals is given below.
INTRODUCTION
/*****C Program for generating prime numbers between two numbers*****/
Automatic test case generation technique is that which can reduce time and cost of the software developed for the different purpose. There are two main aspects of software testing: one is automatic test case generation and the second is adequacy criterion. Automatic test case generation is a process of generating test cases automatically while Adequacy Criterion is a predicate to know whether the testing process has finished [1, 2, 3, 4, 5, 6, 7].
#include #include void main() { int x,y,z,i,j;
Control Flow Graphs and Data Flow Graphs are mostly used for determining the adequacy criterion. In this paper Hybrid Genetic Algorithm is used to generate test cases automatically. With the use of these test cases, bugs can be removed from the software. How much importance of bugs in software, depends on factors such as frequency, correction cost, consequential cost and application cost [9, 10]. If the bugs remain in software then developed software cannot run as fast as actually it should be. At the end of software development phase, the correction cost of the software will increase very fast, so the total application cost will increase if all bugs have not been removed during development of each phase of software development life cycle. [13, 15, 16, 17]
clrscr(); printf("\n Enter the limits for starting and end point\n"); scanf("%d%d",&x,&y); printf("\n"); for(i=x;ii) { printf("\t%d",i); } } getch(); } When CFG is generated for the mutant program it will remain same. IV.
Fig.1. CFG and information about each statement is it control or sequential.
HYBRID GENETIC ALGORITHM FOR SOFTWARE TESTING
Genetic Algorithm is one of the most famous and best heuristic algorithm for generating test cases automatically. The concept of Genetic Algorithm is based on mimicking the survival of fittest among the species generated by random algorithms [11, 14].
All the possible paths for the given program can be easily found in the given figure. Now some mutants are injected in this given program. These are as In the fisrt for loop insteat of i++ it is only i+. In the second for loop insteat of ji/2. In first if instead of i%j it is i/j. In second if instead of j>i/2 it is j>=i. /*****C Program for generating prime numbers between two numbers after injection of mutants*****/ #include #include void main()
2
3rd IEEE International Conference on "Computational Intelligence and Communication Technology" (IEEE-CICT 2017)
TABLE I.
A. Proposed method
MUTATION SCORE
S. No.
No. of test suits
Size of each suit Random
GA
HGA
1
8
7
70
100
100
2
7
3
50
75
100
3
6
7
80
90
100
4
2
10
75
100
100
5
11
15
90
100
100
6
4
6
75
90
90
7
3
7
50
80
100
8
10
9
75
100
100
9
15
12
80
100
100
10
16
14
90
90
100
Mutation Score
In this table we take 10 test suits of different sizes and applied path testing and mutation analysis. After taken three different methods first random method second genetic algorithm (GA) and third our proposed method hybrid genetic algorithm (HGA) we calculated all the mutation score as given in table 1. Comparison chart is given below for the same. Fig.2. Flow chart for proposed method
In this proposed method termination condition is to cover all the given path of a CFG or the maximum generation will cross 1000 iterations. 1) Selection: In the selection process rank based selection process of the individual are used. First selection population has been chosen among the initial individuals. Next time a rank has been assigned to each set with some test cases and these test cases covered maximum paths. 2) Crossover: In crossover operation two points of crossover has been selected and also improved it with some of a probabilistic function. Crossover operation has been applied when mutation score is less than 80% with the mutation probability Pc.
Fig 3. Mutation Score
VI.
3) Mutation: In Mutation operation one bit has been filliped for getting new generation. The crossover operation has been applied only when mutation score is greater than or equal to 80% with the mutation probability Pm.
In automatic test case generation a lot of optimization techniques are applied as ant colony optimization (ACO), PSO and genetic algorithms etc. In this paper automatic test cases for mutation testing are generated with the use of hybrid genetic algorithm. On comparing the random and genetic algorithm we find that mutation is better with hybrid genetic algorithm. The proposed method produces maximum mutation score.
4) Fitness function: Here the fitness function F(x)=1/f(x). The fitness function finds the mutation score. Mutation score=(Number of mutants found/total number of mutants injected) *100.
REFERENCES [1]
V.
CONCLUSION
EXPERIMENTAL SETUP
Mutants are injected in the initial program and now the main work is to identify the mutation score with path coverage.
3
Khan, Rijwan, Mohd Amjad, and Dilkeshwar Pandey. "Automated Test Case Generation using Nature Inspired Meta Heuristics-Genetic Algorithm: A Review Paper." International Journal of Application or Innovation in Engineering & Management (IJAIEM) 3.11 (2014).
3rd IEEE International Conference on "Computational Intelligence and Communication Technology" (IEEE-CICT 2017)
[2]
[3]
[4]
[5]
[6]
[7]
[8]
Khan, Rijwan, Mohd Amjad, "A review on automated test case generation using genetic algorithms,"International Journal of Advanced Research in Computer Science and Software engineering, Dec 2014 Rijwan Khan, Mohd Amjad, “Automatic Generation of Test Cases for Data Flow Test Paths Using K-Means Clustering and Genetic Algorithm” published in International Journal of Applied Engineering Research ,Volume 23, and Issue 1, Jan 2016. Khan, Rijwan, and Mohd Amjad. "Automatic test case generation for unit software testing using genetic algorithm and mutation analysis." 2015 IEEE UP Section Conference on Electrical Computer and Electronics (UPCON). IEEE, 2015. Khan, Rijwan, Mohd Amjad, and Akhilesh Kumar Srivastava. "Optimization of Automatic Generated Test Cases for Path Testing Using Genetic Algorithm." Computational Intelligence & Communication Technology (CICT), 2016 Second International Conference on. IEEE, 2016. Mahajan, Manish, Sumit Kumar, and Rabins Porwal. "Applying genetic algorithm to increase the efficiency of a data flow-based test data generation approach." ACM SIGSOFT Software Engineering Notes 37.5 (2012): 1-5. Girgis, Moheb R., Ahmed S. Ghiduk, and Eman H. Abd-Elkawy. "Automatic Generation of Data Flow Test Paths using a Genetic Algorithm." International Journal of Computer Applications 89.12 (2014): 29-36. Rapps, Sandra, and Elaine J. Weyuker. "Selecting software test data using data flow information." Software Engineering, IEEE Transactions on 4 (1985): 367-375
[9]
[10] [11]
[12]
[13]
[14] [15] [16]
[17]
4
Srivastava, Praveen Ranjan, and Tai-hoon Kim. "Application of genetic algorithm in software testing." International Journal of software Engineering and its Applications 3.4 (2009): 87-96. John H. Holland, Adaptation in Natural and Artificial Systems, The University of Michigan Press, Ann Arbor, MI, 1975. Binitha, S., and S. Siva Sathya. "A survey of bio inspired optimization algorithms." International Journal of Soft Computing and Engineering 2.2 (2012): 137-151. Nirpal, Premal B., and K. V. Kale. "Comparison of Software Test Data for Automatic Path Coverage Using Genetic Algorithm." development 4 (2011): 5.0. Zhang, Na, Biao Wu, and Xiaoan Bao. "Automatic Generation of Test Cases Based On Multi-population Genetic Algorithm." technology 10.6 (2015). Genlin, Ji. "Survey on genetic algorithm." Computer Applications and Software 21.2 (2004): 69-73. Korel, Bogdan. "Automated software test data generation." IEEE Transactions on software engineering 16.8 (1990): 870-879. Korel, Bogdan. "Automated test data generation for programs with procedures." ACM SIGSOFT Software Engineering Notes. Vol. 21. No. 3. ACM, 1996. Pargas, Roy P., Mary Jean Harrold, and Robert R. Peck. "Test-data generation using genetic algorithms." Software Testing Verification and Reliability 9.4 (1999): 263-282.