Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Abstract: Software is built by human so it cannot be perfect. So in order to make sure that developed software does not do
any unintended thing we have to test every software before launching it in the operational world. Software testing is the
major part of software development lifecycle. Testing involves identifying the test cases which can find the errors in the
program. Exhaustive testing is not a good idea to follow. It is very difficult and time consuming to perform. In this paper a
technique has been proposed to do prioritize test cases according to their capability of finding errors. One which is more
likely to find the errors has been assigned a higher priority and the one which is less likely to find the errors in the program
has been assigned low priority. It is recommended to execute the test cases according their priority to find the errors.
International Journal of Computer Science and Informatics ISSN (PRINT): 2231 –5292, Volume-2, Issue-3, 2012
63
Test Case Priortization Using Genetic Algorithm
algorithm. In their approach they proposed a method solution of the problem.(in our case the sequence of
to generate the test cases for classes in object oriented test cases is chromosome and our aim is to optimize
software using a genetic programming approach. This this sequence). For example- for 12 test cases T1, T2,
method represents a tree representation of statements T3……….T12 the sequence is
in the test cases. Strategies for encoding the test cases T1T2T4T6T9T10T12T3T5T7
and using the objective function to evolve them as T8T11
suitable test cases are proposed.[9]
Debasis Mohapatra et al has proposed automated 3.2.1 Evaluate the fitness of generated population-
test case generation and its optimization for path The fitness of a chromosome is defined by an
testing using genetic algorithm and sampling. In this objective function. An objective function tells how
approach they have used genetic algorithm to ‘good’ or ‘bad’ a chromosome is. This objective
optimize the test cases that are generated using the function generates a real number from the input
category- partition and test harness pattern.[10] chromosome. Based on this number two or more
Md. Imrul Kayes proposed test case chromosome can be compared.
prioritization for regression testing based on fault
dependency[11]. He present a metric APFDD which 3.2.2 Apply selection for individual-
measure fault dependency detection rate and In general the selection is depend on the fitness
presented an algorithm to improve APFDD. value of the chromosome. The chromosome with
Zheng Li et al have applied search algorithm for higher or lower value will be selected base on the
regression test case prioritization.[12] problem definition.
Gregg Rothermel et al have performed a control
experiment to access prioritization techniques using 3.2.3 Apply crossover and mutation-
mutation faults.[13] Parents are choose and randomly combined. This
Gregg Rothermel et al have proposed several technique for generating random chromosome is
techniques for developing prioritize test cases in called crossover. There exist two type of crossover-
regression testing phase. They also rate of fault a. Single point crossover
detection of these techniques.[14] b. Multiple point crossover
For example- suppose two sequences for test
3. KEY RESEARCH CONCEPT cases is
P1: T1T2T3T4T5T6T7T8T9
3.1 Genetic algorithm and
Genetic algorithm is stochastic search technique, P2: T4T2T5T7T8T1T6T9T2
which is based on the idea of selection of the fittest Then using one point crossover offspring will be-
chromosome. C1: T1T2T3T4T8T6T9T5T7
In genetic algorithm, population of chromosome C2: T4T3T5T7T6T8T9T1T2
is represented by different codes such as binary, real For C1 write first part of the P1 as it is and then
number, permutation etc. genetic operators(i.e. write second part of P2 with constraint that a test case
selection, crossover, mutation) is applied on the has not been added in to C1.
chromosome in order to find more fittest For doing mutation two genes selected randomly
chromosome. The fitness of a chromosome is defined along the chromosome and swapped with each other.
by a suitable objective function. As a class of For example- when T3 and T9 get selected
stochastic method genetic algorithm is different from randomly
a random search. While genetic algorithm carry out a T1T2T3T4T8T6T9T5T7
multidimensional search by maintaining population T1T2T9T4T8T6T3T5T7
of potential user, random methods consisting of a
combination of iterative search methods and simple 3.2.4 Termination criteria-
random search methods can find a solution for a The termination criteria can be selected in the
given problem. One of the genetic method’s most different ways such as- reaching the predefined
attractive feature is to explore the search space by fitness value, the number of generation or a non-
considering the entire population of the existing difference in the fitness values of each
chromosome.[15] generation.
The steps of genetic algorithm are as- In our approach we used a fixed generation
1. Generate population (chromosome) number as a termination criteria.
2. Evaluate the fitness of generated population
3. Apply selection for individual
4. Apply crossover and mutation
5. Evaluate and reproduce the chromosome
3.2 Generate population(chromosome)-
Initially population is randomly selected and
encoded. Each chromosome represent the possible
International Journal of Computer Science and Informatics ISSN (PRINT): 2231 –5292, Volume-2, Issue-3, 2012
64
Test Case Priortization Using Genetic Algorithm
T9 30 10 15 5, 6, 7, 8, 9, 10,
Figure 1: steps in genetic algorithm [11] 11, 12, 14,
17, 18, 19, 20,
21
4. PROPOSED TECHNIQUE
T10 30 10 15 18, 19, 20, 21,
35
In this section we present technique for test case T11 30 20 40 Obtuse 24, 25
prioritization using genetic algorithm. angled
Let’s say a program has test case suite T, now if triangle
we make modification in the program p, suppose T12 30 20 40 Obtuse 15, 16, 20, 21
modified program is P’, so in order to test program P’ angled
we will generate a prioritize sequence of test cases triangle
from test case suite T , on the basis of the line of code Assume that lines 5, 8,10,15,20,23,28,35 are
modified. modified and the modified lines of code covered by
In this paper the following genetic parameter will each test case are shown in the table below-
be used- Test case Number of modified lines
1. Fitness function : The following objective T1 2
function (fitness function) will be used- T2 4
Fitness value (F) = Σ {order * (number of T3 1
modified lines covered by test cases)} T4 3
For example- a test case sequence is T5 2
T1_T2_T3_T4 and T1, T2, T3 and T4 covers 2,1,5,3 T6 2
modified lines of code respectively. Then fitness T7 5
value for this sequence will be T8 2
F= (2*4) + (1*3) + (5*2) + (3*1) 16 T9 4
In this T1 has order 4 and it covers 2 lines of T10 1
code,T2 has order 3 and it contains 1 line of code , T3
T11 0
has order 2 and it covers 5 line of code and T4 has
T12 2
order 1 and it covers 3 lines of code.
Table 2: number of modified lines covered by test
2. Crossover : In this proposed paper we will
case
use one point cross over with crossover probability
Now we apply genetic algorithm, on this data.
Pc=0.33.
Chromos- Fitness Norm Cummu Sele Rec
3. Mutation : In this paper we will use mutation ome value alized lative ctio om-
probability Pm=0.2. it means that 20% of the genes value probabi n of men
will be muted within a chromosome. lity rand dati
Example -Test cases with execution history [1]. om on
Test A B C Expected Execution num
case Output History ber
ID T1T2T 196 196/5 0.342 0.3 Chr
T1 30 20 40 Obtuse 8, 9, 10, 11, 12, 3T4T5 73=0. omo
angled 13 T6T7 342 som
triangle T8T9T e1
T2 30 20 40 Obtuse 8, 9, 10, 11, 12, 10T11T
angled 13, 14, 15,16, 12
triangle 20, 21, 22 T2T4T 189 189/5 0.671 0.4 Chr
T3 30 20 40 Obtuse 10, 11, 12, 13 6T8T10 73=0. omo
angled T12T1 329 som
triangle T3T5 e2
T4 30 20 40 Obtuse 10, 11, 12, 13, T7T9T
angled 14, 15, 16, 20, 11
triangle 21, 22 T5T6T 188 188/5 1 0.2 Chr
International Journal of Computer Science and Informatics ISSN (PRINT): 2231 –5292, Volume-2, Issue-3, 2012
65
Test Case Priortization Using Genetic Algorithm
8T9T12 73=0. omo algorithm a large number of time we will get a nearly
T1T7 328 som optimized solution. As we know that genetic
T11T2 e1 algorithm does not always gives optimum solution,
T3T4T but if we run this algorithm fairly large number of
10
time then we will get nearly optimum solution.\
On the basis of this random number we got to
REFERENCES
know that the first random no recommends the
chromosome 1 that is 1. K.K. Aggarwal, Y. Singh, “Software Engineering”, New Age
(T1T2T3T4T5T6T7T8T9T10 International Publishers, 2006.
T11T12) because the selected random no lies
between 0-0.342. Second random number 2. Yu-Chi Huang, Chin-Yu Huang, Jun-Ru Chang and Tsan-
Yuan Chen “Design and Analysis of Cost-Cognizant Test
recommends the chromosome 2 that is Case Prioritization Using Genetic Algorithm with Test
(T2T4T6T8T10T12T1T3T5T7 History”, IEEE 34th Annual Computer Software and
T9T11) because the random number lies Applications Conference 2010.
between 0.342-0.671. The third random number
3. Sangeeta Sabharwal, Ritu Sibal, Chayanika Sharma
recommends the chromosome “Prioritization of Test Case Scenarios Derived from Activity
1(T1T2T3T4T5T6T7T8T9T10 Diagram Using Genetic Algorithm”,international conference.
T11T12) because the selected random number on Computer & Communication Technology[ICCCT 10].
lies between 0-0.342.
4. Sangeeta Sabharwal, Ritu Sibal, Chayanika Sharma “A
So now we have the following member in our Genetic Algorithm Based Approach For Prioritization of Test
mating pool: Case Scenarios in Static Testing “, International Conference
T1T2T3T4T5T6T7T8T9T on Computer & Communication Technology (ICCCT)-2011.
10T11T12
5. James H. Andrews, Member, IEEE, Tim Menzies, Member,
T2T4T6T8T10T12T1T3T5 IEEE, and Felix C.H. Li “Genetic Algorithms for
T7T9T11 Randomized Unit Testing”, IEEE transaction on software
T1T2T3T4T5T6T7T8T9T Engineering, vol. 37, no. 1, January/February 2011.
10T11T12
6. Mohsen Fallah Rad, Farshad Akbari Ahmad Javan Bakht
Now we will apply the one point cross over on “Implementation of Common Genetic and Bacteriological
these chromosome and will generate the new off Algorithms in Optimizing Testing Data in Mutation Testing”.
springs.
T1T2T3T4T5T6T7T8T9T 7. Ruchika malhotra and mohit garg “An Adequacy Based Test
Data Generation Technique Using Genetic Algorithms”
10T11T12 Journal of Information Processing Systems, Vol.7, No.2, June
T2T4T6T8T10T12T1T3T5 2011.
T7T9T11
T1T2T3T4T5T6T7T8T9T 8. Ciyong Chen , Xiaofeng Xu , Yan Chen , Xiaochao Li and
Donghui Guo “A New Method of Test Data Generation for
10T11T12 Branch Coverage in Software Testing Based on EPDG and
On applying one point cross over the selected Genetic Algorithm”.
population we will get the following off springs-
T1T2T3T4T5T6T7T9T11 9. Nirmal Kumar Gupta and Dr. Mukesh Kumar Rohil “Using
Genetic Algorithm for Unit Testing of Object Oriented
T8T10T12 Software”, in First International Conference on Emerging
T2T4T6T8T10T12T1T9T11 Trends in Engineering and Technology.
T3T5T7
T1T2T3T4T5T6T7T9T11 10. Debasis Mohapatra Prachet Bhuyan Durga P. Mohapatra
“Automated Test Case Generation and Its Optimization for
T8T10T12 Path Testing Using Genetic Algorithm and Sampling”, 2009
Now suppose if the crossover probability is 0.3 WASE International Conference on Information Engineering.
then we select 2 chromosomes from the offspring and
one from the parents based on the fitness function 11. Md. Imrul Kayes “Test Case Prioritization for Regression
Testing Based On Fault Dependency”.
value.
This process is repeated certain fixed number of 12. Zheng Li, Mark Harman and Robert M. Hierons “Search
iterations, on repeating this procedure multiple times, Algorithm For Regression Test Case Priortization”.
we will get the nearly optimum solution.
13. Hyunsook Do and Gregg Rothermel “A controlled
Experiment Assessing Test Case Prioritization via Mutation
5. CONCLUSION Faults”.
International Journal of Computer Science and Informatics ISSN (PRINT): 2231 –5292, Volume-2, Issue-3, 2012
66