efficient software test case generation using genetic algorithm based graph theory by: dr. velur...

22
Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

Upload: simon-townsend

Post on 24-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory

By: Dr. Velur Rajappa Arun Birabar Satanik panda

Page 2: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

ABSTRACT

In this the new and efficient test case is generated using Graph theory based Genetic algorithm other than using modeling based testing approach for generating test cases for software testing, for the generation of the test cases first the directed graph is created with all the intermediate states. In this cross over operation is performed and this genetic testing method is mostly used in network testing and system testing. This testing works as an alternative testing where modeling based testing does not produce the expected output.

Page 3: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

THE NEED OF TEST CASES FOR SOFTWARE ENGINEERING

Software testing is an essential part of software development whichguaranteed the validation and verification process of the software. Inorder to do so we must have to adopt the process of mapping thesoftware for all its transition states and individually validating theoutput for a set of given input. For a given part of software we will bewriting a set of test cases called test suites.

In order to find out how a test case is valid we do not have definitemechanism. We basically depend on the testers understanding of therequirement. In this Process we have lot of human error and his basic skilllevel taken into consideration. This leads to the inclusion of bugs in thesystem after testing also. To over come this there are many approachalready being taken and getting implemented. Hence we propose thegenetic graph based approach to find a better solution of the issue.

Page 4: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

INTRODUCTION TO GRAPH THEORY

The graph theory approach will beneeded for the implementation of allthe graphs to representation of thestates of the system. We willimplement the total system state asdirected graph. A simple graph,denoted G = (V,E), consists of a setOf vertices, V, and a set of edges, E,where the edges are lines thatConnect pairs of vertices's.Figure 1(a), (b), (c), and (d) show examplesof graphs.

Page 5: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

GENETIC ALGORITHMS

The method we are going to use when it comes tosearching for a counter example is GeneticAlgorithms (GA).

Genetic algorithms are best

defined as a pollution based search algorithmbased loosely on concepts from biologic evolution. Since the key data structure used inGenetic Algorithms is bit strings, we must have away to represent a graph as a bit string. TheSections includes:-Representation -Tournament-Initialization -Recombination-Crossover operation -Replacement-Mutation -Repeat-Evaluation of fitness

Representation of a graph as a Bit String

Page 6: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

INITIALIZATION

The next step is to select a random sample ofIndividuals from the search space. In this case, the searchspace is all the different graphs of size 43 (approximately6.76 x 10271). From this, a sample of 250 individuals wasselected. The random samples are independent from runto run.

Page 7: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

CROSSOVER OPERATION

In the crossover operation, two solutions are sexuallycombined to form two new solutions or offspring. The parents arechosen from The population by a function of the fitness of thesolutions. Three methods exist for selecting the solutions for thecrossover operation. The first method uses probability based on thefitness of the solution. If is the fitness of the solution Si and is thetotal sum of all the members of the population, then the probabilitythat the solution Si will be copied to the next generation is:

Page 8: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

CROSSOVER OPERATION

Page 9: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

MUTATION

Mutation is another important feature of genetic programming. Twotypes of mutations are possible. In the first kind a function canonly replace a function or a terminal can only replace a terminal. Inthe second kind an entire sub tree can replace another sub tree.

Page 10: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

EVALUATION OF FITNESS

Now that we have 250 individuals, we must conduct tournamentsto see which graphs are better than others. In order to conduct thetournaments, we must have a way of ranking or ordering theindividuals. This is called the fitness function. Upon creation of ourfitness function, examination of current maximum cliquealgorithms and approximation algorithms was very helpful. In ourcase, the fitness of an individual is the number of cliques of size 5in the graph plus the number of independent sets of size 5 in thegraph. This was chosen because of the direct application to theproblem. The possible fitness values for an individual from thisfitness function range from 0 to 962598 (taken from K43). A graphwith fitness value of 0 would have no cliques of size 5 and noIndependent sets of size 5 and thus would be the desired counterexample.

Page 11: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

TOURNAMENT

Now that each individual has a fitness value, tournaments can beconducted in order to rank our population. Using a tournament sizeof 2, individuals compete for chances to produce offspring. In ourcase, 2 individuals are chosen at random from the population.These two individual’s fitness values are compared and the onewith the better (i.e. smaller) fitness value is chosen to be a parent.This can be related to the “survival of the fittest” idea in biology.

Page 12: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

RECOMBINATION

The better individuals are now chosen to produce offspringThrough point mutation and one-point crossover. We chose to havea 50% Mutation rate, meaning that mutation takes place at approximately the same frequency as one point crossover. Pointmutation involves randomly choosing one of our 903 bits in our bit string and flipping it, i.e. making it a 0 if it was a 1 and vice versa.This translates to the removal or addition of an edge to the graph,thus creating a new graph.

Contd..

Mutation Recombination Technique

Page 13: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

One-point crossover involves taking two individuals andmerging them together. To do this, a random point, n,must be chosen such that the new individual consists ofbits 0 to n-1 from the first parent and bits n to 902 fromthe second parent.

RECOMBINATION

One-point Crossover Recombination Technique

Page 14: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

REPLACEMENT

Now that new offspring are created, they replace the poorerindividuals in the population as was decided by the tournaments.In the standard replacement, all of the new offspring are replacedat the same time at the end of one generation. In our case,however, we are using a steady state system with 25%replacement. This means that one individual is replaced every timea tournament completes. After 25% of the population (63individuals) is replaced, one generation is complete.

Page 15: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

REPEAT

Evaluation of Fitness, Tournament, Recombination, andReplacement are repeated for as many generations as is chosen bythe user. In our case 400 generations was chosen because afterabout 400 generations there was little improvement in the bestfitness. This is due to the decreased variation in the population,meaning that all of the individuals began to look the same orStrikingly similar.

GA Life Cycle

Page 16: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

OUR APPROACH

We propose the solution to be a combination of graph theory andgenetic algorithm. At first we will draw the general graph of all thestates of the software. To fulfill the total state of the system wecan use finite automata and Turing machine. Once the graph isready we will give the flow direction on every edge. Then the newlyBuilt directed graph will be taken from generating the dual graphpairs to find the test cases from it. Each dual pair will be taken forthe gene for the input of genetic algorithm. In this process we willbe generating a set of chromosome, which will produce the testsuite.

Page 17: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

THE STEPS TO BE FOLLOWED

We will get a model of the system for all its probable states andthat will represent as a dual graph in the following manner. 1. Create a dual graph of the original graph (i.e., a graph in which the arcs of the original graph are converted to nodes). 2. Everywhere in the original graph that arc 1 is an incoming to a node and arc 2 is outgoing from the same node, create an arc in the dual graph from node 1 to node 2. For instance, in the left hand graph in, arc “a” is incoming to the node from which arc “b” is outgoing; therefore in the dual graph (on the right hand side of Figure 6), there is an arc from node “a” to node “b”. 3. Right Figure shows the completed dual graph. 4. Eulerize the dual graph (by duplicating arcs to balance node polarities) 5. Traverse the Eulerized graph, noting the names of the nodes that you pass.

Contd. . .

Page 18: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

The generated sequence will be the length 2-switch covers for thegraph. (You can see that all 2-link combinations, including “b c”, “bf” and “b g” are generated.)

a b c b f e c b g d e f e g

Dual Graph generation

Contd. . .

Page 19: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

Next step is to convert this sequence into genetic populationby encoding the duals in 0 and 1 format. For this purpose we haveto create a matrix of the order of the number of dual found in thegenerated graph. On that population we have used the mutationand cross over operation to find the child as a pair of new link. Theoperation has been repeated till we covered the whole graph atleast once. From the out put we have produced the test caseswhich belongs to only one test suit for the given system understudy.

Dual Graph generation

Page 20: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

CONCLUSION

In this way if we find the state optimal system thenThe probability of the untested paths for a given systembehavior will be minimized and the test coverage will besignificantly increase.

Page 21: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

REFERENCES

1. D.E.Goldberg, Genetic Algorithms in Search, Optimization,and Machine Learning, Addison-Wesley, 1989.2. Beizer, B. (1990) Software Testing Techniques, 2nd Edition.3. Gross, J. and Yellen, J. (1998) Graph Theory and its Applications.4. Murthy, C. and B. Manoj. 2004. Ad hoc wireless networks architectures and protocols. Prentice Hall, Upper Saddle River, New Jersey.5. Rappaport, T. 1996. Wireless communications: principles and practice. Prentice Hall, Upper Saddle River, New Jersey.6. Stine, J and G. Veciana. 2004. A paradigm for quality-of service inwireless ad hoc networks using synchronous signaling and node states.IEEE Journal on Selected Areasin Communication. 22 (7): 1301-1321.7. Andrew S. Tanenbaum, Computer Networks. Fourth Edition, PrenticeHall.8. Rex Black. Critical Testing Processes: Plan, Prepare, Perform, Perfect9. Elfriede Dustin. Effective Software Testing: 50 Specific Ways to ImproveYour Testing.10. K. Thulasiraman and M.N.S. Swamy. Graphs: Theory and Algorithms. John Wiley & Sons 1992.

Page 22: Efficient Software Test Case Generation Using genetic Algorithm Based Graph Theory By: Dr. Velur Rajappa Arun Birabar Satanik panda

THANK YOU

ANY QUESTIONS ?