Vous êtes sur la page 1sur 33

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

ABC Tester - Artificial Bee Colony Based Software Test Suite Optimization Approach
D. Jeya Mala (1), V. Mohan (2)
(1) Department of Computer Applications. Thiagarajar College of Engineering (India). (2) Department of Mathematics. Thiagarajar College of Engineering (India)
E-mail: vmohan@tce.edu E-mail: djmcse@tce.edu

ABSTRACT
In this paper we present a new, non-pheromone-based test suite optimization approach inspired by the behavior of biological bees. Our proposed approach is based on ABC (Artificial Bee Colony Optimization) which is motivated by the intelligent behavior of honey bees. In our proposed system, the sites are the nodes in the Software under Test (SUT), the artificial bees modify the test cases with time and the bees aim is to discover the places of nodes with higher coverage and finally the one with the highest usage by the given test case. Since ABC system combines local search methods carried out by employed bees with global search methods managed by onlookers and scouts, we attain near global optima. We investigate whether this new approach outperforms existing test optimization approach based on Genetic Algorithms (GA) in the task of software test optimization. Taking into account the results of our experiments, we conclude that (i) the proposed approach uses fewer iterations to complete the task; (ii) is more scalable, i.e., it requires less computation time to complete the task, and finally (iii) our approach is best in achieving near global optimal solution.
Keywords: Software under Test (SUT), Software Testing, Artificial Bee Colony Optimization (ABC), Coverage, Software Test Optimization, Genetic Algorithm (GA).

1- INTRODUCTION Software testing process typically consumes at least 50% of the total cost involved in software development [1]. This percentage might

even be higher if the software is safety critical [2]. Automation of the testing process is desirable both to reduce the testing cost and also to improve the quality of software. Many of the automation activities focus on the test script level automation and execution of the test scripts in capture and playback model. Most software development organizations automate test-related tasks. But, the test automation process cannot be generalized. While testing tools available in the market might not be applicable in all test environments, they may be useful in some of them. The automation of test data generation is still a research area since the 1

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

automated testing tools simply generate test data without any consideration of amount of time spent for test data generation and selection of test cases based on the test adequacy criteria. It is up to the tester to choose the test cases from the generated test cases and they have to stop the testing process whenever they feel exhaust or the specific test adequacy criterion is met. Hence, this process involves a lot of human intervention and thus leads to lack of achieving the expected goal. As Phil McMinn briefed in his paper [6], exhaustive enumeration of a programs input is infeasible for any reasonably-sized program, yet random methods are unreliable and unlikely to exercise deeper features of software that are not exercised by mere chance. Previous efforts have been limited by the size and complexity of the software involved, and the basic fact that in general, test data generation is an undecidable problem. The application of meta-heuristic search techniques to test data generation is a possibility which offers much promise for these problems. Meta-heuristic search techniques are high-level frameworks which utilize heuristics in order to find solutions to combinatorial problems at a reasonable computational cost. Such a problem may have been classified as NP-complete or NP-hard, or be a problem for which a polynomial time algorithm is known to exist but is not practical. The application of artificial intelligence (AI) techniques in Software Engineering (SE) is an emerging area of research that brings about the cross fertilization of ideas across two domains [3,9]. A number of published works have begun to examine the effective use of AI for SE related activities that are inherently knowledge intensive and human-centered. Recent research and development of ABC based systems are focusing mostly on applications such as financial decision making systems, transportation, manufacturing, aerospace, military and so on [19]. In our approach, we extended the functionality of the bee to do the testing and monitoring activity so that, it reduces the manual work and improves the confidence on the software by testing it with the coverage of the given software. In our approach we used state coverage, code coverage, branch coverage and path coverage as coverage based test adequacy criteria. As per Horgaon, these coverage based metrics are used to reveal errors in a powerful way [4].

1-1 GLOBAL OPTIMIZATION


In engineering, economic and scientific studies, quantitative decisions are frequently modeled by applying optimization concepts and tools. The decisionmaker or modeler typically wants to find the absolutely best decision which corresponds to the minimum (or maximum) of a suitable objective function, while it satisfies a given collection of feasibility constraints. The objective function expresses overall (modeled) system performance, such as profit, utility, loss, risk, or error. The constraints originate from physical, technical, economic or possibly some other considerations [11].

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

1-2 SOFTWARE TEST SUITE OPTIMIZATION


A test suite is a set of several test cases for a component or system under test, where the post condition of one test is often used as the precondition for the next one [12]. The test suite optimization process involves generation of effective test cases in a test suite that can cover the given SUT within less time. Random test cases are generated by a random walk in the Software under Test (SUT) starting at any source node and terminating at a destination or sink node constrained by the edge probabilities. But this leads to an unlimited source of tests in which the selection of efficient test cases is very difficult [7]. In our approach we applied ABC with state coverage, code coverage, branch coverage and path coverage as test adequacy criteria for test suite optimization. Artificial Bee Colony (ABC) optimization is a non-pheromone based swarm intelligence approach motivated by the intelligent behavior of honey bees; the colony consists of three groups of bees: employed, onlookers and scouts. The proposed approach based on Artificial Bee Colony (ABC) optimization represents each test case as a possible solution in the optimization problem and happiness value - a heuristic introduced to each test case corresponds to the quality or fitness of the associated solution. Here the bees were implemented as agents that perform the test suite optimization activities seamlessly. In the proposed approach, the test cases are selected by an intelligent search through the Software under Test (SUT) based on the happiness value associated with each node. The objective function is to maximize the fitness value by finding the sum of the fitness value associated with each node based on constraint satisfaction. Now, the approach generates a few efficient test cases that can cover the model within less amount of time. In the case of software systems having dynamic behavior, the testing process is much more a complex task because of its multi-threaded processing nature. An ABC model that can interact with the developer and the SUT will speed up the development and testing process and also helps in getting an insight into the execution flow in the system.

1-3 PROBLEM ENVIRONMENT


o The Software under Test (SUT) is given as input. Let n be the cyclomatic complexity value that indicates there are n independent test paths in the Software under Test (SUT). Given n test suites each consists of several test cases that must be processed on m test paths / sequences.

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

1-4 OBJECTIVE CRITERIAN


The objective of the approach is to generate an efficient test suite that can cover the SUT within less time and cost by applying intelligent search through the SUT using the parallel behavior of a group of three bees.

1-5 PROBLEM FORMULATION


The general software test suite optimization problem is provided in terms of the test adequacy criterion. The optimization problem is a multi-objective optimization problem in which the objective function (1) indicates maximizing the coverage of the SUT and (2) indicates minimizing the size of the test suite. Max. Coverage (SUT) Min. Size (test-suite) (2) The objective function for test suite optimization in our proposed approach is: Max Happiness_value (test-case) (3) Sub to. Happiness_value (test-case) = 1 if Coverage (test-case) =100% 0 otherwise (4) The objective function in (3) is to maximize the happiness value of each test case by identifying the node with higher coverage value. The constraint (4) indicates the happiness value based on coverage of test case for each node. At each stage during the search, the current search point must be checked to see that it satisfies all types of constraints. Only the search points or nodes which satisfy all the constraints are eligible for selection, otherwise the execution of the problem can result in run-time errors. For example, consider the generation of test data that forms the test path TPath = (S1, S2, S3Sn), Where Si represents the node/ state in the SUT. Initially, optimization is performed to find a set of test data x1, which executes state S1. Keeping S1 as the initial search point, a search is then performed to find a set of test data x2 which executes S1S2 and the process continues until a set of test data xn is found to execute the complete test sequence TPath. Test Case - As per IEEE, do 178b, a test case is a set of inputs, execution preconditions, and expected outcomes developed for a particular objective, such as to exercise a particular program path or to verify compliance with a specific requirement. Test adequacy Criteria - To ensure the testing process, an empirical technical investigation is conducted to provide the adequacy of the test cases in testing the SUT. This may be Statement Coverage, Branch Coverage, Condition Coverage, Mutation Score etc. 4 (1)

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

There are several coverage based test adequacy criterion available (Beizer, 1990). In our approach, we used, state coverage, code coverage, branch coverage and path coverage as test adequacy criteria. State Coverage - Unlike other coverage-based criteria, state coverage measures the extent of checks of program behavior. Let Ni be the set of output-defining nodes of SUT subject to test ti, and Vi be the set of covered output defining nodes of SUT subject to test ti. The optimistic state coverage of test suite T is | Vi| | Ni| (5)

Code Coverage-In code testing, criteria based on coverage of the building blocks of programs can be used to determine the adequacy of tests. Code coverage is a measure used in software testing. It describes the degree to which the source code of a program has been tested. It is a form of testing that inspects the code directly and is therefore a form of white box testing. Branch Coverage - Branch coverage adequacy criterion verifies whether each control structure (such as an if statement) is evaluated both to true and false conditions. Branch Coverage % = No. of Branches covered / Total No. of branches Path Coverage based Test Adequacy Criterion - A test T is considered adequate if it tests all paths. In case the program contains a loop, then it is adequate to traverse the loop body zero time or once. Test Optimization To maximize the profit of coverage and minimize the total number of test cases needed.

2- LITERATURE REVIEW 2-1 EXISTING WORK ON SOFTWARE TEST OPTIMIZATION


The literature review shows that: the research on software testing problems has centered mostly on software test optimization; intelligent software testing techniques are extensively proposed to solve software test optimization problems; several meta-heuristic search techniques such as applying rules, metaheuristics (like Genetic Algorithm (GA), Ant Colony Optimization (ACO), Tabu Search, Simulated Annealing, Bacteriologic Algorithm (BA), etc.), Fuzzy logic and Neural Networks (NN), Hybrid Genetic Algorithm (HGA) and other approximation methods [13-18] have been proposed for some specific types of problems in test optimization; and there is still a need for a more effective solution approach to more general problems such as test suite optimization and there is a need for developing 5

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

models and efficient algorithms to achieve optimization by satisfying the specified test adequacy criteria. The major observations derived as part of the literature study are: In neural networks based approach, the drawbacks are its black-box data processing structure; a slow convergence speed; difficulty in programming, training and verification of rules. In Tabu search based approach, more amount of memory is required in terms of long term memory to avoid stuck up at local optima and short term memory to remember all the test cases in the current search. The experiments with Genetic Algorithms (GA) were not satisfactory even when the mutation rate is excessively increased compared to usual application of GA (mutation rates lower than 2%). Moreover, the results are not stable (strike up at local optima); the convergence is slow and non-explicit memorization of best individuals. The drawbacks of Ant Colony Optimization (ACO) include higher length test sequences and repetition of nodes within the same sequence without any advantage on test adequacy criteria. The approach proposes to increase the number of ants to increase the coverage, which violates the optimality requirement criterion. The assumption made by ACO itself has some serious drawbacks: the assumption is that, the two ants are started at an initial node, and during random selection of next node, they will go to the same next node; since, the process is random; one cannot expect that the two ants always go to the same next node at different instances of time.

2-2 LITERATURE SURVEY ON APPLICATION OF ABC BASED APPROACH IN OPTIMIZATION PROBLEMS


Artificial Bee Colony optimization that belongs to non-pheromone based swarm intelligence algorithms is considered suitable for many optimization based problems. Dervis Karaboga et.al, applied Artificial Bee Colony (ABC) Optimization Algorithm for Solving Constrained Optimization Problems. In their paper, they showed superior performance of ABC in solving a set of constrained optimization problems [21]. Dervis Karaboga et.al, proposed the use of ABC in solving numerical function optimization. They compared the efficiency of ABC with other optimization algorithms such as GA, PCO and PS-EA and proved that ABC outperformed them [21]. Dusan Teodorovic et.al, proposed a bees algorithm to solve difficult combinatorial optimization problems. In their paper, in addition to proposing the Bee Colony Optimization (BCO) as a new metaheuristic, they also described two BCO algorithms called the bee system (BS) and the fuzzy bee 6

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

system (FBS). In the case of FBS, the agents (artificial bees) use approximate reasoning and rules of fuzzy logic in their communication and acting. In this way, the FBS is capable to solve deterministic combinatorial problems, as well as combinatorial problems characterized by uncertainty [24]. Li-Pei Wong et.al, presented an improved Bee Colony Optimization algorithm with Big Valley landscape exploitation as a biologically inspired approach to solve the Job Shop Scheduling problem. They compared the experimental results of the proposed algorithm with Shifting Bottleneck Heuristic, Tabu Search Algorithm and Bee Colony Algorithm with Neighborhood Search on Taillard JSSP benchmark and they showed that it is comparable to these approaches [23]. Duan TEODOROVI et.al, proposed a bee colony optimization approach to complex transportation problems [22]. Adil Baykaso lu et.al, applied Artificial Bee Colony (ABC) Algorithm to Generalized Assignment Problem in the book on Swarm Intelligence: Focus on Ant and Particle Swarm Optimization [25]. Alok Singh applied Artificial Bee Colony (ABC) Algorithm to the leafconstrained minimum spanning tree problem. Given an undirected, connected, weighted graph, the leaf-constrained minimum spanning tree (LCMST) problem seeks on this graph a spanning tree of minimum weight among all the spanning trees of the graph that have at least l leaves. In this paper, they proposed an artificial bee colony (ABC) algorithm for the LCMST problem. They compared the performance of ABC approach against the existing best approaches. They demonstrated the superiority of the new ABC approach over all the other approaches based on computational results. The new approach obtained better quality solutions in shorter time [26]. R. Srinivasa Rao et.al, applied Artificial Bee Colony Algorithm for Optimization of Distribution Network Configuration for Loss Reduction [27]. Nurhan Karaboga proposed a new design method based on artificial bee colony algorithm for digital IIR filters [28]. Mohammad et.al, have applied honey-bee mating optimization algorithm on clustering in data mining. They applied honey-bee mating technique to avoid local optima in cluster analysis. They also compared the efficiency of the approach with other approaches such as GA, SA, TS, and ACO, on several well known data sets. Their finding shows that the proposed algorithm works well than the best one [29].

2-3 NEED FOR ABC BASED APPROCH IN SOFTWARE TEST SUITE OPTIMIZATION
The drawbacks of existing knowledge based approaches discussed in our literature study have made us to focus on an alternate approach which has 7

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

the advantages of population based approaches without the problem of local optima. The literature study on ABC has provided us a lot of proof on using it as an alternate optimization approach to hard optimization problems. In the light of the above consideration, we applied ABC for software test suite optimization which is a NP-hard problem. Further our paper is divided into the following sections: Section 3 Artificial Bee Colony Optimization (ABC) An Introduction Section 4- Proposed Approach ABC Model based Software Test Optimization Section 5 Related Work GA based Software Test Optimization Section 6 - Implementation of ABC Tester Section 7 Experimental Evaluation and Comparison ABC Vs. GA

3- ARTIFICIAL BEE COLONY OPTIMIZATION (ABC) AN INTRODUCTION


Artificial Bee Colony (ABC) is one of the most recently defined algorithms by Dervis Karaboga in 2005, motivated by the intelligent behavior of honey bees. It is as simple as Particle Swarm Optimization (PSO) and Differential Evolution (DE) algorithms, and uses only common control parameters such as colony size and maximum cycle number [19]. ABC as an optimization tool provides a population-based search procedure in which individuals called foods positions are modified by the artificial bees with time and the bees aim is to discover the places of food sources with high nectar amount and finally the one with the highest nectar [19]. In ABC model, the colony consists of three groups of bees: employed, onlookers and scouts. In this system, the artificial bees fly around in a multidimensional search space and some employed and onlooker bees choose food sources depending on the experience of themselves and their nest mates, and adjust their positions. Some scouts bees fly and choose the food sources randomly without using experience. If the nectar amount of a new source is higher than that of the previous one in their memory, they memorize the new position and forget the previous one [19]. Employed bees goes to their food source and come back to hive and dance on this area. The employed bee whose food source has been abandoned becomes a scout and starts to search for finding a new food source. Onlookers watch the dances of employed bees and choose food sources depending on dances.

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

3-1 ABC ALGORITHM


The steps of the basic ABC algorithm are given below: Initial food sources are produced for all employed bees. REPEAT Each employed bee goes to a food source in her memory and determines a neighbor source, then evaluates its nectar amount and dances in the hive Each onlooker watches the dance of employed bees and chooses one of their sources depending on the dances, and then goes to that source. After choosing a neighbor around that, she evaluates its nectar amount. Abandoned food sources are determined and then, they are replaced with the new food sources discovered by scouts. The best food source found so far is registered. UNTIL (requirements are met) In ABC which is a population based algorithm, the position of a food source represents a possible solution to the optimization problem and the nectar amount of a food source corresponds to the quality (fitness) of the associated solution. The number of the employed bees is equal to the number of solutions in the population. At the first step, a randomly distributed initial population (food source positions) is generated. After initialization, the population is subjected to repeat the cycles of the search processes of the employed, onlooker, and scout bees, respectively. An employed bee produces a modification on the source position in her memory and discovers a new food source position. Provided that the nectar amount of the new one is higher than that of the previous source, the bee memorizes the new source position and forgets the old one. Otherwise she keeps the position of the one in her memory. After all employed bees complete the search process; they share the position information of the sources with the onlookers on the dance area. Each onlooker evaluates the nectar information taken from all employed bees and then chooses a food source depending on the nectar amounts of sources. As in the case of the employed bee, she produces a modification on the source position in her memory and checks its nectar amount. Providing that its nectar is higher than that of the previous one, the bee memorizes the new position and forgets the old one. The sources abandoned are determined and new sources are randomly produced and replaced the abandoned ones by artificial scouts. Thus, ABC system combines local search methods, carried out by employed and onlooker bees, with global search methods, managed by scouts, attempting to balance exploration and exploitation process. 9

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

4- PROPOSED APPROACH ABC MODEL BASED SOFTWARE TEST OPTIMIZATION


In ABC model, we have the following types of bees o Employed, o Onlooker and o Scouts As shown in Fig. 1, we associated each of these bees into the following in our test optimization model o Employed bee Search agent/ bee o Onlooker bee Selector agent/bee o Scouts bee Replace agent/bee In our model, the system consists of three bees: Search Bee, Replace Bee and Selector Bee. It is understood that, there is exactly one test case needed for each test path. The test cases to be executed for the corresponding test paths are determined by following the path in the state space. Initially, a random population of test cases is generated. The Search Bee searches for an executable state in the SUT for each test case as it goes to an executable state in the test path as per the information in the knowledge source and determines the best next neighbor node/state. This determination is done by analyzing all the neighbor nodes/states from the current node/state based on the selected test cases coverage. Then, it evaluates the fitness value (nectar amount) of each node surrounding the current node for the selected test case. The fitness value is nothing but the happiness value heuristic which is calculated based on the coverage of a test case for each neighbor node. Then the selection of the best node to transit is chosen based on this heuristic. The Selector Bee watches the search bee and chooses the test cases depending upon the fitness value associated with each test case. If the node is not feasible or not covered by a particular test case, then the node is removed from memory and the Selector Bee starts a new search for finding the node with higher feasibility in that path. Based on that, a happiness value or coverage measure is associated with each test case. A test case with highest fitness value or coverage measure is remembered and all the other test cases are removed from the memory. If the Selector Bee finds that the selected test cases are not efficient in terms of their coverage, then the Replace Bee generates a new population of test cases and replaces the test cases in the existing test case set with new test cases. This cycle is repeated till we reach the termination condition of either the maximum number of cycles (MCN) is reached or the specified coverage criterion is above 95%.

10

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

SUT

Search Bee

Selector Bee

Replace Bee Optimized Test Suite Repository

Figure 1 ABC based test optimization Framework

4-1 ABC TESTER ALGORITHM


Initialize the population of test cases Repeat Step 1 - The employed bee/ search bee applies the test cases to the first executable node in the SUT. Once the employed bee finishes its search process by applying each test case to the node, the fitness value (coverage value) of the test cases along with the node information is then returned by the employed bees. Step 2 - The onlooker bee/selector bee takes this information as input and evaluates the coverage value of each test case taken from the employed bees. Then it finds out the test case that has the highest coverage value of the given node. The test case along with the covered node information is memorized. Step 3 - Then the nodes which are adjacent to the covered node are explored by the employed bees. Now the fitness value of the selected test case against the explored neighborhood nodes is evaluated by the onlooker bee. Step 4 - The node with the highest fitness value is selected and appended with the existing selected node to indicate the test path. The test case along with the covered node information is stored in the optimized-test suite-repository. Step 5 - Other nodes except the covered node and the test cases other than the selected test case are abandoned and they are stored in temporary-node-list and temporary-test case-list respectively. 11

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

Step 6 If a test path is not complete, then repeat steps 3 to 6. Otherwise, the nodes and test cases from the temporary-node-list and temporary-test case-list are selected for the next test path generation by the employed bees. Step 7 - If the onlooker bee/selector bee finds that the selected test cases are not efficient, then the scout bee/replace bee generates a new population of test cases and replaces the test cases in the temporary-test case-list with new test cases. Until the specified termination criterion is met. (Maximum number of cycles (MCN) is reached or the specified coverage criterion is met (above 95%))

4-2 WORKING PRINCIPLE OF THE PROPOSED APPROACH


The proposed approach is a population based approach, in which each test case represents a possible solution in the optimization problem and the fitness value of each test case corresponds to the quality or fitness of the associated solution. The working principle of the proposed approach is shown in Fig.2. At the first step, a randomly distributed initial population of test cases is generated. After initialization, the population is subjected to repeat the cycles of the search processes of the bees. The Search Bee monitors each test case by evaluating its coverage at each node. If the node is covered by that test case, then it finds the neighbor states by searching through the knowledge source. Then it finds the feasibility of the said test case based on its coverage in those nodes. Depending on that, the fitness value of each node is updated. After the Search bee completes its search process, it shares the information of the test cases and nodes with their highest fitness values with the Selector Bee. Each Selector bee evaluates the fitness value taken from all the test cases and chooses a test case depending upon the fitness value of them If none of the nodes have been covered by the given test case, the Selector Bee produces a modification on the node selection using the information in the knowledge base, and discovers a new node. Provided that the fitness value of the new node is higher than that of the previous one, the bee memorizes the new node along with the test case that covered it and removes the old one. Otherwise it keeps the position of the old node in the knowledge base. If the Selector Bee finds that the selected test cases are not efficient in covering the nodes, it communicates the information to the Replace Bee. The Replace Bee then generates new population of test cases and communicates it to the Search Bee to continue its search process. 12

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

Figure 2 ABC Tester Working Principle

4-3 DETAILED PSEUDO CODE OF THE ABC ALGORITHM


We applied the following pseudo code for our test case optimization problem. 1. 2. 3. 4. 5. Initialize the population of test cases xij. Evaluate the population cycle =1 Repeat Produce new test cases vij in the neighborhood of xij for the employed bees using the formula vij = xij + qij (xij - xkj) (6)

Where k is a solution in the neighborhood of I, q is a random number in the range [-1, 1] and evaluate them. 6. Apply greedy selection process between xi and vi. 7. Calculate the probability values of test cases xi by means of their fitness values using the equation: Pi=fiti / fiti Where i=1 to SN (7) 13

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

In order to calculate the fitness values of solutions we employed the following equation: fiti= 1 / 1+hv(i) if hv(i) >=0 1+ abs (hv(i) if hv(i) <0 (8)

Fitness of each node is decided by the happiness value (hv) associated with each node based on constraint satisfaction. For a>b, ci(n) =(b-a) and if ci(n) < 0, hv(i) = MIN, otherwise H (ci (n))=MAX or 0 (9) (ii) For a>=b, ci(n) = (b-a) and if ci(n) <= 0, hv(i) = MIN, otherwise H (ci (n))=MAX or 0 (10) (iii) For a<b, ci(n) = (b-a) and if ci(n) > 0, hv(i) = MIN, otherwise H (ci (n))=MAX or 0 (11) (iv) For a<=b, ci(n) = (b-a) and if ci(n) >= 0, hv(i) = MIN, otherwise H (ci (n))=MAX or 0 (12) (v) For a==b, ci(n) = (b-a) and if ci(n) = 0, hv(i) = MIN, otherwise H (ci (n))=MAX or 0 (13) (vi) For a!=b, ci(n) = (b-a) and if ci(n) != 0, hv(i) = MIN, otherwise H (ci (n))=MAX or 0 (14) (vii) For a OR b, hv(i) = hv(ci(a))+hv(ci(b) (15) (viii) For a AND b hv(i) = MIN (hv(ci(a), hv(ci (b)) (16) Pi values are normalized into [0,1] 8. Produce new test cases vi for the onlookers from the test cases xi, selected depending on Pi and evaluate them. 9. Apply the greedy selection process for the onlookers between xi and vi. 10. Determine the abandoned test case, if exists and replaces it with a new randomly produced test case xi for the scout using the equation : xij = minj+rand(0,1)*(maxjminj) (17) The scout waggle dances to indicate the new test case generation. 11. Memorize the best test case achieved so far using the fitness value. 12. cycle = cycle+1 13. Until cycle=Max. Cycle Number (MCN) (i)

5- RELATED WORK - GENETIC ALGORITHM (GA) BASED TEST SUITE OPTIMIZATION


GA Mimics the evolution of natural species in searching optimal solution. So, genetic algorithm has been exploited to produce test cases automatically [7,13]. Test cases are described by chromosomes, which includes information on the object/component to be created, methods to be invoked and values to 14

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

be passed as input. Genetic algorithms contain the functions like crossover, mutation, selection and evaluation [13]. The first step is to represent a legal solution to the problem by a string of genes that can take on some value from a specified finite range or alphabet. This string of genes, which represents a solution, is known as a chromosome. Then an initial population of legal chromosomes is constructed at random. At each generation, the fitness of each chromosome in the population is measured. The fitter chromosomes are then selected to produce offspring for the next generation, which inherit the best characteristics of both the parents. After many generations of selection for the fitter chromosomes, the result is hopefully a population that is substantially fitter than the original.

5-1 PSEUDO-CODE OF GA ALGORITHM


1. Choose initial population 2. Evaluate the fitness of each individual in the population 3. Repeat a. Select best-ranking individuals that covers the path to reproduce b. Breed new generation through crossover and mutation genetic operations) and give birth to offspring c. Evaluate the individual fitnesss based on path coverage of the offspring

d. Replace worst ranked part of population with offspring 4. Until <terminating condition>

5-2 GENERATION OF TEST CASES USING SGA


5-2-1 Chromosomal Representation Each chromosome represents a legal solution to the problem and is composed of a string of genes. In the case of binary GA, the binary alphabet {0,1} is often used to represent these genes but sometimes, depending on the application, real GA in which integers or real numbers are used. 5-2-2 Test Case Construction - One point crossover and Mutation One Point Crossover - Fragmenting the selected population at some point m and recombine the 0..m-1 portion of first member and m...n of the second member, as well as recombine the 0..m-1 portion of second member and mn of the first member.

15

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

Say for example, For the variables a, b and c Test Case 1: 1, 2, 1 Test Case 2: 1, 1, 1 After 1-point cross-over at the second position, we get new test cases as follows: Test Case 11: 1, 1, 1 Test Case 21: 1, 2, 1 This new generation of test cases is then evaluated based on their effectiveness and then either selection or removal will be done. 5-2-3 Mutation This operation is used to change the member at gene level and reproduce the remaining genes for the creation of new generation. In software testing, the test case sets are considered as the population and individual test case is considered as member and the possibility of individual variables value are method call are considered as the genes. Parent 1 Test Case 1: 1, 2, 1 Parent2-TestCase 2: 1, 1, 1 After mutation operator is applied to these test cases, we will get the new generation of test cases like, Child 1 - Test Case 11: 2, 2, 1 Child 2 - Test Case 21: 1, 1, 2 Now this new generation of test cases will be evaluated and the procedure is repeated. 5-2-4 Test Case Evaluation Code Coverage criterion The population that has most favorable features can be assigned with higher fitness value for evaluation. In software testing, the favorable feature is revealing more number of errors. The test case with highest path and branch coverage criterion should be selected as they can reveal errors in their execution. Test Case 11s Coverage% is 50% Test Case 21s Coverage% is 76% Parent 1s Coverage% is 60% Parent 2s Coverage% is 70%

16

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

5-2-5 Test Case Selection Filtering Function Selecting the best parent from the current population is called as selection process. This will lead to incremental solution. The test case that has higher fitness value is selected as parent for next generation. After the evaluation is done, Parent1 test case is replaced by Test Case 21. Then during the next iteration, this modified parent will be used for the generation of test cases (offspring).

5-3 PROBLEMS WITH GA


In many problems with sufficient complexity, GAs may have a tendency to converge towards local optima rather than the global optimum of the problem. Operating on dynamic data sets is difficult, as genomes begin to converge early on towards solutions which may no longer be valid for later data. GAs cannot effectively solve problems in which the only fitness measure is right/wrong, as there is no way to converge on the solution. (No hill to climb.) In these cases, a random search may find a solution as quickly as a GA. The implementation and evaluation of the fitness function is an important factor in the speed and efficiency of the algorithm. Creating the initial set of test case is very easy, but improving the test case quality is in need of lot of effort. By using GA we can automate the improvement of test case. The basic set of test cases carries information that can be optimized to create better test cases by cross-over and mutation of the test cases. In our previous paper on test case optimization using Hybrid Genetic Algorithm [18], we showed the experimental results of GA and hence they were not explained in detail in this paper.

6. IMPLEMENTATION ABC TESTER


The proposed approach ABC Tester has been implemented in Java. The sample screen shots were shown in Appendix-B. In this paper, to illustrate the working of ABC Tester, two case studies have been implemented.

6-1 CASE STUDY 1: COMPARISON OF THREE VALUES


Sample problem taken is comparison of values among three numbers, a very simple problem. Here the decision making process is done based on the value of the parameters a, b and c. The data types of all these variables are integer.

17

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

// Program to compare three values


main() {int a, b,c; 1 read a,b,c; 2 if(a>b) 3 Printf(A is bigger than B); 4 else if (b>c) 5 Printf(B is bigger than C); 6 else if(a>c) 7 Printf(A is bigger than C); 8}

Figure 3 Sample Code for comparing three values For the code in Fig.3, the cyclomatic complexity value is 4 which means that there are four independent paths in the given problem. We have an initial set of test cases for each of these paths created randomly. xij be the initial set of test cases for each of the path as below: Let xj = {1,1,2} for path 1 {1,1,1} for path 2, {1,1,1} for path3 and {1,1,1} for path4. It is indicated in table 1. Table 1 Independent paths and initial set of random test cases:
S.No. 1. 2. 3. 4. Path 1-2-3 1-2-4-5 1-2-4-6-7 1-2-4-6-8 Test Case - (a,b,c) 1,1,2 1,1,1 1,1,1 1,1,1

Where i=1 to 3 for variables a,b and c and j=1 to cyclomatic complexity that indicates the total number of paths in the program. xij indicates a test case i related to path j here it is a triple a,b,c. i=1 means it is for a, 2 for b and 3 for c. qij=(-1 to 1) which is a random number generated during program execution.

18

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

Now, vij = xij+qij(xij-xkj) ,where k is a solution in the neighborhood of i and q is a random number. Path 1: For i=1 to 3, j=1, k = (i+1) % size of the test case (size = 3 since we have 3 variables) v11=x11+q11(x11-x21) = 1+(1) (1-1) = 1 v21=x21+q21(x21-x31)=1+(-1)(1-2) = 2 v31=x31+q31(x31-x11)=1+(0)(2-1) = 1

Hence, vi = {1,2,1} where i=1 and j=1 Compare the fitness of xij and vij. Apply greedy selection process between xi and vi for path j=1. This must be done for all paths of j. Calculate the probability Pi for the solution xi /vi by means of their fitness values: Pi = fiti / sum(i=1 to SN) fiti Here, the fitness values are calculated using the formula (2) and (3). Based on them, new test cases vi for the onlookers from the solutions xi are selected depending on Pi and evaluate them. Apply the greedy selection process between xi and vi. Unfortunately, both of these test cases have their fitness values as 0 and so we need to abandon these solutions and replace them with new solutions by using scout bees. Determine the abandoned solution and replace it with new randomly produced solution xi for the scout using the formula: o xij = minj + rand(0,1) * (maxj minj) Here the minimum valued test case is {1,1,1} and maximum valued test case is {2,1,1}. Hence, x11 = {1,1,1} + 1 * {2,1,1} {1,1,1}

19

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

= {1,1,1} + 1*{1,0,0} = {1,1,1}+{1,0,0} = {2,1,1} Now, new xij is {2,1,1}. This test case has highest fitness value for the path j=1 and now scout will start a new search by using this new set of test cases. Memorize the best test case achieved so far based on their fitness (probability value). cycle = cycle +1 Until cycle = max. cycle no. (MCN) The above procedure is coded in Java and we applied the said approach each unit of the software under test. We found that the results were generated so fast because of the operation of three agents working in parallel way. Since, the bees work in parallel the decision making process is simple. After the scout bee identifies a new best solution, it waggle-dances in the dancing area. Here, we have a status flag used by the scout bee to indicate it. The results of ABC based framework in test case optimization is shown in Table 2. Table 2 Results of ABC based framework in Test Case Optimization
Test Case (a,b,c) 1,1,2 1,2,1 2,1,1 2. 1-2-4-5 1,1,1 1,2,1 3. 1-2-4-6-7 1,1,1 1,2,1 2,2,1 4. 1-2-4-6-8 1,1,1 Probability value based on Fitness Value 0 0 1 0 1 0 0 1 1 Coverage % (Test sequence) 0% 0% 100% 0% 100% 0% 0% 100% 100%

S.No.

Test Sequence

1.

1-2-3

6-2 CASE STUDY 2 - TRIANGLE CLASSIFICATION PROBLEM


Consider a simple program to classify a triangle. Its input is a triple of positive integers (a,b,c) and the data type for input parameters ensures that these will 20

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

be integers greater than 0 and less than or equal to 100. The program output may be one of the following: [Scalene Triangle; Isosceles Triangle; Equilateral Triangle, Not a triangle]. This problem is chosen as the bench mark problem because it is the most famous problem in software testing. // Triangle Classification Problem main() { int a,b,c; boolean isatriangle; 1.Print(Triangle Classification Problem); Print(Enter three integers which are sides of a triangle); Read(a,b,c); 2. If(a<(b+c)) && (b<(a+c)) && (c<(a+b)) 3.isatriangle=true; 4. Else isatriangle=false; 5. If (isatriangle) { 6.If(a==b) xor (a==c) xor (b==c) && !(a==b) && (a==c) 7.Print(Isosceles Triangle); 8. If(a==b) && (b==c) 9. Print(Equilateral Triangle); 10. If(a!=b) && (a!=c) && (b!=c) 11. Print(Scalene Triangle); 12. } 13. Else print(Not a triangle); 14. } Figure 4 Sample code for Triangle Classification Problem For the code in Fig.4, the Cyclomatic Complexity value is 5. There are five independent test paths available in the given SUT and are listed in table 3. The blocks of executable statements are given in Fig. 4.

21

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

Table 3 Independent paths


Path # 1. 2. 3. 4. 5. Path 1-2-4-13-14 1-2-3-5-6-7-8-10-12-14 1-2-3-5-6-8-9-10-12-14 1-2-3-5-6-8-10-12-14 1-2-3-5-6-8-10-11-12-14

Table 4 Sample Test Cases with expected output and path coverage details
Test Case 1 2 3 4 5 6 7 8 9. 10. A 4 1 1 5 2 2 3 3 2 5 B 1 4 2 5 2 3 2 4 3 4 C 2 2 4 5 3 2 2 5 4 6 Expected Output Not a Triangle Not a Triangle Not a Triangle Equilateral Isosceles Isosceles Isosceles Scalene Scalene Scalene Path Covered 1-2-4-13-14 1-2-4-13-14 1-2-4-13-14 1-2-3-5-6-8-9-10-12-14 1-2-3-5-6-7-8-10-12-14 1-2-3-5-6-7-8-10-12-14 1-2-3-5-6-7-8-10-12-14 1-2-3-5-6-8-10-11-12-14 1-2-3-5-6-8-10-11-12-14 1-2-3-5-6-8-10-11-12-14

The initial test cases are generated as a random population generation. Let Xij be the initial set of test cases. = {2,2,3} where j=2 (path =2) , i=1 to 3 for parameters a, b and c. And the Xij values are a=2,b=2 and c=3. The search bee searches the node corresponds to it and it identified that, the test case is suited for node 2 in path2. Hence, the fitness value is high for node 2, which makes the selector bee to select this node as the best node to traverse. Then the neighbor nodes are explored. And the test case is selected for node6 which is meant for Isosceles Triangle. This exploration is continued until it reaches a node that has no more frontiers to explore. The test case is selected for path j=2. 22

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

Then the next generation of test cases is generated using the formula 1: o o o V13= 2+1 * (2-2) = 2 V23=2+ (1) * (2-3) = 3 V33=3+(1) * (3-2) = 4

= {2,3,4} which is fit for node 2 and so the test case is selected and Vij exploration is done by the selector bee. While exploration, the search bee identifies test case is fit for node10 which is meant for Scalene Triangle, and now the process continues till no more frontiers to explore. The test case is selected for path j=3. Since, there are no more test cases available for selection, the scout generates a new test case using the formula 4: = minj + rand(0,1)*(maxj-minj) Xij = {2,2,3} + (-1) * {2,2,4} {2,2,3} = {2,2,2} Xij Hence the test case has the highest fitness value for node 2 and then selector bee selects it and explores the neighbor nodes. Now the node 8 is selected as the best node to explore and finally the test path 3. The process is continued by all the bees in parallel to cover the entire SUT. Again, the next test case is generated by scout bee using the formula 4: = minj + rand(0,1) * (maxj minj) Vij = {2,2,2} + (1) * {2,2,4} {2,2,2} Vij = {2,2,4} which leads to the path 1 meant for Not a triangle. This is repeated till all the test paths have been covered or a required path coverage percentage has been achieved. Hence the entire test case generation is done with coverage based analysis by three different types of bees working in parallel. In our case studies, we showed the coverage results of variables of type integer. For other data types like float and double, the value range of q should be determined in such a way that, it will produce the test cases in floating point and double based representations. For char data type, the ASCII equivalent of values is used for generation of test cases. Similar to that for Boolean data types, either true or false values should be generated for the variables which are achieved by toggling the values of q during each cycle. Hence, the proposed approach is well suited for any type of problem that involves different data types.

23

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

7. EXPERIMENTAL EVALUATION AND COMPARISONABC Vs.GA


We conducted a variety of case studies for finding the efficiency of our approach against the existing approach based on GA.

7-1 EXPERIMENTAL SETUP


The proposed approach is compared with the performance of GA in test case optimization. The experimental setup is done as in the table 5. Table 5 Experimental Setup for ABC and GA
Parameter setup Type of algorithm Fitness Function No. of Cycles Termination Criteria Population of test cases Generation Pheromone / Non Pheromone based Communication about selection ABC Based Population Based Nectar Amount / Happiness value based on Path Coverage MCN (Prescribed by the tester) Max. no. of cycles / Acceptable path coverage measure Using the formula of xij and vij Non-Pheromone Based Waggle Dance / Status flag GA Based Population Based Fitness value based on Path Coverage MAX. (Prescribed by the tester) Max. no. of cycles / Acceptable path coverage measure Using Crossover and Mutation Non-Pheromone Based Status flag

7-2 ABC BASED OPTIMIZATION

Path Coverage - ABC


Path Coverage %
100 80 60 40 20 0 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 No.of cycles
Figure 5 Path Coverage of the test cases in ABC 24

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

For ABC based test optimization framework, the parameters mentioned in table 3 were applied. The initialization of test cases is done as a random process. Then the subsequent generations were carried out by the three bees using the formulae 6 to 17. The selection of test cases was done based on the heuristic happiness value that shows the coverage of the SUT. For example, the selection of test cases as x [1] =2, x [2] =1, x [3] =1 yields the result as coverage of sequence 1-2-3. The number of test runs is increased to get more accurate values.

7-3 GA BASED OPTIMIZATION

Figure 6 Path Coverage of individuals in GA For GA based test case optimization, we used the parameters as mentioned in table 3. Then crossover and mutation operations were applied to generate the further generations. At the end of each generation, the fittest individuals are identified by finding the coverage metric. The individuals that have the highest coverage metric were survived and were used as parents for further generations. This process is continued till we reach the acceptable path coverage value or the number of test cycles. From the figures 5 and 6, we see that, the optimization of the test cases based on their fitness value is higher and is steadily improving in ABC. Whereas in GA, the test cases improvement is non-linear and usually strikes at local optima. The time taken for ABC is less since at the same time three different agents are working in parallel and the solution is obtained by collaborative learning (waggle dance) among them. In the case of GA, there is no such collaborative learning available and hence it usually takes more time for generating the solution.

7-4 FURTHER CASE STUDIES AND EXPERIMENTAL RESULTS


The approach has been tested against five academic problems shown in table 6 and four industrial problems listed in table 7. They are ranging from simple to complex based on the lines of code and methods per class.

25

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

The test objects have been tested using GA and the proposed ABC tester algorithm. The results were gathered in terms of their path coverage, test runs and time taken for the entire test case optimization process and is shown in tables 8 and 9. Table 6 Academic Problems
S.NO. [1] [2] [3] [4] [5] 1. 2. 3. 4. 5. Academic Test Problem Timetable Generation Binary Search Tree Construction Online quiz system Students marks processing system Attendance monitoring system Test Object No ATP1 ATP2 ATP3 ATP4 ATP5

Table 7 Industrial Problems


S.No. [6] [7] [8] [9] 1. 2. 3. 4. Industrial Test Problem Anti-money laundering system Multi-point software Ticket Monitoring system Stock Management System Test Object No ITP1 ITP2 ITP3 ITP4

The results indicated that, when compared to GA, ABC based test optimization produced high coverage of test cases within minimal number of test runs. Table 8 Results of Academic test problems
GA Based Optimization S.No. Test Problem Path Coverage % 70% 65% 75% 90% 85% Generations Time ABC Based Optimization Path Coverage % 95% 98% 97% 99% 96% Cycles Time

1. 2. 3. 4. 5.

ATP1 ATP2 ATP3 ATP4 ATP5

100 200 70 300 150

20 45 18 52 29

50 80 35 50 70

10 14 8 10 12

The results gathered from academic problems indicated that, even after we increased the number of cycles in test case generation, the path coverage percentage is low in GA when compared to ABC. 26

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

Table 9 Results of Industrial Test Problems


S.No. 1. 2. 3. 4. Test Problem ITP1 ITP2 ITP3 ITP4 GA Based Optimization Path Coverage % 70% 75% 80% 68% Generations 500 300 400 180 Time (sec) 40 35 52 20 ABCBased Optimization Path Coverage % 92% 98% 97% 98% Cycles 150 75 125 60 Time 22 20 25 10

Similarly, for industrial test problems; we identified that, for complex systems which involve multiple data types the performance of ABC is superior and takes only less time for test case generation process.

8-CONCLUSION
In this paper, we demonstrated the application of ABC in software test suite optimization and showed the superiority of the proposed approach over the existing GA based approach. Problems with GA include no memorization, non linear optimization, risk of suboptimal solution and delayed convergence. There is no guarantee for global optimal solution even when it may be reached. But, ABC model based test suite optimization generates near global optimal results and it converges within less number of test runs. As a future work, different versions of ABC have to be applied for test suite optimization and conduct an analytical study in finding the best ABC version in near global optimal solution generation for software testing. Also, the performance of ABC can be compared with Ant Colony Optimization (ACO) for efficiency evaluation.

REFERENCES
[1] Rudolf Ramler, Klaus Wolfmaier, Economic perspectives in test automation: balancing automated and manual testing with opportunity cost, Proceedings of the international workshop on Automation of Software Test, pp.15-23, 2006. [2] Michael Grottke, Kishor S. Trivedi, Fighting Bugs: Remove, Retry, Replicate, and Rejuvenate, IEEE Computer, Vol.40, No.2, pp. 107-109, 2007. [3] Briand, L. C., On the many ways Software Engineering can benefit from Knowledge Engineering, Proc. 14th SEKE, Italy, pp. 3-6, 2002. [4] Horgan, J., London, S., and Lyu, M., Achieving Software Quality with Testing Coverage Measures, IEEE Computer, Vol. 27 No.9 pp. 60-69, 1994. [5] Li, H., Lam, C.P., Optimization of State-based Test Suites for Software Systems: An Evolutionary Approach, International Journal of Computer & 27

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

Information Science, Vol. 5, No. 3, pp. 212-223, 2004. [6] McMinn, P., Search-based Software Test Data Generation: A Survey, Software Testing, Verification and Reliability, Vol.14, No. 2, pp. 105- 156, 2004. [7] McMinn, P., Holcombe, M., The State Problem for Evolutionary Testing, Proc. GECCO 2003, LNCS Vol. 2724, pp. 2488-2500, Springer Verlag, 2003. [8] Huaizhong Li and C.Peng Lam, Software Test Data Generation using Ant Colony Optimization, Transactions on Engineering, Computing and Technology, ISSN 1305-5313, 2004. [9] Pedrycz, W., Peters, J. F., Computational Intelligence in Software Engineering, World Scientific Publishers, 1998. [10] Tracey, N., Clark, N., .Mander K., and McDermid, N., A Search Based Automated Test Data Generation Framework for Safety Critical Systems, in Systems Engineering for Business Process Change (New Directions), Henderson P., Editor, Springer Verlag, 2002. [11] H. Edwin Romeijn, Panos M. Pardalos, Handbook Of Global Optimization, Volume 2, Kluwer Academic Publishers, 2002 [12] B. Beizer, Software Testing Techniques, Thomson Computer Press, 2nd edition, 1990. [13] R. Pargas, M. Harrold, R. Peck. Test-data generation using genetic algorithms, Software Testing, Verification and Reliability, Vol. 9, No.4, pp.263--282, 1999. [14] Meenakshi Vanmali, Mark Last, Abraham Kandel, Using a neural network in the software testing process, International Journal of Intelligent Systems, Vol.17, No.1, pp. 45 62, 2002 [15] Zhang, Zili, Zhou, Fuzzy Logic Based Approach For Software Testing, International Journal Of Pattern Recognition And Artificial Intelligence, pp.709-722, 2007 [16] Hlne Waeselynck, Pascale Thvenod-Fosse, Olfa Abdellatif-Kaddour, Simulated annealing applied to test generation: landscape characterization and stopping criteria, Empirical Software Engineering, Vol.12, No.1, pp.3563, February 2007. [17] Eugenia Daz, Javier Tuya, Raquel Blanco, A tabu search algorithm for structural software testing, Computers and Operations Research, Vol. 35, No.10, pp. 3052-3072, 2008. [18] D.Jeya Mala, Dr.V.Mohan, Hybrid Tester - An Automated Hybrid Genetic Algorithm Based Test Case Optimization Framework for Effective Software Testing, International Journal of Computational Intelligence: Theory and Practice, Vol.3 No.2, pp 81-94, 2008. 28

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

[19] D. Karaboga, B. Basturk, On The Performance Of Artificial Bee Colony (ABC) Algorithm, Applied Soft Computing,Volume 8, Issue 1, January 2008, pp. 687-697,2007 [20] Dervis Karaboga, Bahriye Basturk, Artificial Bee Colony (ABC) Optimization Algorithm for Solving Constrained Optimization Problems, LNCS- Book on Foundations of Fuzzy Logic and Soft Computing, pp. 789-798, 2007. [21] Dervis Karaboga, Bahriye Basturk, A powerful and efficient algorithm for numerical function optimization: artificial bee colony (ABC) algorithm, Journal of Global Optimization, Volume 39, Number 3, pp. 459-471, 2007. [22] Dusan Teodorovic, Panta Lucic, Goran Markovic, Mauro D Orco, Bee Colony Optimization: Principles and Applications, Proceedings of Neural Network Applications in Electrical Engineering, pp. 151-156, 2006. [23] Li-Pei Wong, Chi Yung Puan, Malcolm Yoke Hean Low, Chin Soon Chong, Bee colony optimization algorithm with big valley landscape exploitation for job shop scheduling problems, Applied Soft Computing, Volume 8 , Issue 1,pp. 687-697, 2008. [24] Duan Teodorovi, Mauro Dell, Bee Colony Optimization A Cooperative Learning Approach To Complex Transportation Problems, Advanced OR and AI Methods in Transportation, pp 51-60, 2006. [25] Adil Baykasolu, Lale zbakr and Pnar Tapkan, Artificial Bee Colony Algorithm and Its Application to Generalized Assignment Problem, Book on Swarm Intelligence: Focus on Ant and Particle Swarm Optimization, 2007. [26] Alok Singh, An artificial bee colony algorithm for the leaf-constrained minimum spanning tree problem, Applied Soft Computing, Volume 9, Issue 2, pp. 625-631, 2009 [27] R. Srinivasa Rao, S.V.L. Narasimham, M. Ramalingaraju, Optimization of Distribution Network Configuration for Loss Reduction Using Artificial Bee Colony Algorithm, Proceedings Of World Academy Of Science, Engineering And Technology, Volume 35, pp 709-715, 2008. [28] Nurhan Karaboga, A new design method based on artificial bee colony algorithm for digital IIR filters, Journal of the Franklin Institute, Volume 346, Issue 4, pp. 328-348, 2009. [29] Mohammad Fathian, Babak Amiri and Ali Maroosi, Application of honeybee mating optimization algorithm on clustering, Applied Mathematics and Computation, Volume 190, Issue 2, pp. 1502-1513, 2007.

29

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

APPENDIX A Sample Code A sample code for binary search tree construction is given below for which the path coverage metric has been calculated. //Binary Tree Node Construction public class BinaryTreeNode { private BinaryTreeNode left; private BinaryTreeNode right; private Comparable obj; public BinaryTreeNode(Comparable x) { obj = x; left = null; right = null; } public void insert(BinaryTreeNode z) { if (z.obj.compareTo(obj) == 0) return; if (z.obj.compareTo(obj) < 0) if (left == null) left = z; else left.insert(z); else if (right == null) right = z; else right.insert(z); } public BinaryTreeNode search(Comparable x) { if (x.compareTo(obj) == 0) return this; if (x.compareTo(obj) < 0) if (left == null) return null; else return left.search(x); else if (right == null) return null; else return right.search(x); }} //Binary Tree Construction public class BinaryTree { 30

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

private BinaryTreeNode root; public BinaryTree() { root = null; } public void insert(BinaryTreeNode z) { if (root == null) root = z; else root.insert(z); } public boolean search(Comparable x) { if (root == null) return false; BinaryTreeNode n = root.search(x); if (n != null) return true; return false; }} Figure A -1 - Bench Mark Problem Binary Search Path Coverage Criterion Evaluation for Binary Search Program class BinaryTree { private BinaryTreeNode root; public BinaryTree(String tg1) {root = null;} public String insert(BinaryTreeNode z,String tg2) { tg2=tg2+2; if (root == null) { root = z; tg2=tg2+3; } else { root.insert(z); tg2=tg2+4; } return tg2; } public String search(Comparable x,String tg3) { tg3=tg3+5; if (root == null) { 31

Int.J. of Software Engineering, IJSE Vol.2 No.2 July 2009

tg3=tg3+6; return tg3; } BinaryTreeNode n = root.search(x); tg3=tg3+7; if (n != null) {tg3=tg3+8;} else {tg3=tg3+9;} return tg3; }} Figure A-2 - Path Coverage Criterion Evaluation for Binary Search Program

APPENDIx B

Figure B1 ABC Tester Initial Test Case Generation Fig. B-1 shows initial set of test cases for case study 1. The happiness value and path coverage details based on happiness value for each path are calculated using search agent/bee and are shown in Fig. B-2. The selection is shown in Fig. B-3.

32

ABC Tester - Artificial Bee Colony Based Software

Mala and Mohan

Figure B-2 Happiness value calculation and path coverage % of initial set of test cases

Figure B-3 Selected test cases along with their Path coverage %

33

Vous aimerez peut-être aussi