Abstract
Software testing contributes a strategic role in software development, as it underrates the cost of software development. Software testing can be categorized as: testing via code or white box testing, testing via specification or black box and testing via UML models. To minimize the issues associated with object-oriented software testing, testing via UML models is used. It is a procedure which derives test paths from a Unified Modelling Language (UML) model which describes the functional aspects of Software Under Test (SUT). Thus, test cases have been produced in the design phase itself, which then reduces the corresponding cost and effort of software development. This early discovery of faults makes the life of software developer much easier. Also, there is a strong need to optimize the generated test cases. The main goal of optimization is to spawn reduced and unique test cases. To accomplish the same, in this research, a nature-inspired meta-heuristic, Moth Flame Optimization Algorithm has been offered for model based testing of software based on object orientation. Also, the generated test cases have been compared with already explored meta-heuristics, namely, Firefly Algorithm and Ant Colony Optimization Algorithm. The outcomes infer that for large object-oriented software application, Moth Flame Optimization Algorithm creates optimized test cases as equated to other algorithms.
Keywords
Introduction
Testing of software is the vital activity in the development of software life cycle. For the successful implementation of any software, it should be tested efficiently [1]. Moreover, about 50% of development cost inculcates the cost of software testing [2]. Also, for the development of good quality software, various software design paradigms have been used. Object-oriented is one of the software design paradigm that has been used widely in literature due to its numerous advantages [3, 4]. Researchers in their work [5, 6] emphasize the advantages of using object-oriented paradigm over other designparadigms.
However, the powerful features of object-orientation impose various risks and challenges to software testing [7]. In object-oriented system, due to encapsulation, state of object may not be observable and controllable from outside [7], which in turn increases the complexity of the testing activity. Here, in object-oriented system, complexity of testing has moved from within the code module to interface between them, which makes the integration testing an expensive activity [8]. Kung et al. [9] categorized these problems as: a) understanding problem, b) complex inter-dependency problem, c) testing problem due to object state behavior, and d) problem due to support of particular tool.
Because of the above stated problems, optimization and efficient test case generation of object-oriented software is needed critically. Numerous techniques have been used in the literature for the same [10–14]. Xin-She-Yang compared the optimization problem to the process of treasure hunting [15] and suggested the concept of random walk which is the main feature of modern search algorithms. Thus, evolutionary meta-heuristics design the efficient optimization algorithms by the constant improvement of search agents on the basis of fitness function [15]. Empirical studies [16–19] also suggested that optimization via nature-inspired meta-heuristics produce better results than the traditional optimization techniques. Also, irrespective of the generation of software test cases in the development phase, it is better to find the test cases in the software modelling phase itself. It will save both the cost and time of software testing process. This evolves the concept of model based testing. Hence, this model based testing extracts even those faults that are very difficult to extract via code based testing[20–22].
As, the information regarding the software system is disbursed among several views, it is a very thought provoking process to analyze Unified Modelling Language (UML) models. A state chart diagram is one such model which provides the states that a particular object can attain in the whole program execution and also the transitions among those states.
Thus, in this paper, optimal test paths have been generated by using state transition diagram integrated with our proposed Moth Flame Optimization alg-orithm (MFO) [23]. MFO algorithm has already been applied in variety of areas [19, 25]. Here, we are proposing it for creation of test paths. After that, the spawned test paths have been compared with other nature-inspired heuristics: 1) Firefly Algorithm (FA), and 2) Ant Colony Optimization Algorithm (ACO). This paper is arranged as follows:
Section 2 gives the background effort done in the area related to model based object-oriented testing using evolutionary algorithms. Section 3 discusses the nature-inspired meta-heuristics and object-oriented benchmarks selected in this study. Section 4 communicates the proposed MFO algorithm along with its flowchart. Section 5 provides the experimental evolution of MFO on the selected benchmarks. In Section 6 a comparison has been drawn among already existing and our proposed meta-heuristics. This article ends with Section 7, which concludes this analysis.
Background work
In this segment, a study of numerous research articles associated to optimization of object-oriented testing via model based testing and integrated with nature-inspired algorithms has been provided.
S.K Swain et al. [26] integrated state and activity diagrams to generate an intermediate diagram named as state-activity diagram (SAD). They proposed an algorithm for the production of test cases from activity and state transition diagram. Their approach provides a stronger level testing in which object interactions are also captured. However, they do not employ the use of nature-inspired evolutionary algorithms in their work.
A. Bouchachia et al. [27] applied Genetic Algorithm (GA) and ACO for the testing of object-oriented software articulated via finite state machine. P.R. Srivastava et al. [28] applied Cuckoo Search Algorithm (CS) for the generation of optimal test paths in testing based on state diagram. They found that CS algorithm provides better test paths than GA and ACO. H. Li and C.P. Lam [29] used ACO algorithm for automatic test case generation of state based software testing. P.R. Srivastava [30] proposed and applied ACO for the automated and complete handling of all the state transitions of the software.
M. Shirole et al. [31] used an extended flow graph. They projected framework based on GA to produce test cases integrated with state diagram. They concluded that their approach provided the improved results. P.R. Srivastava et al. [32] applied CS and Tabu Search (CSTS) algorithm for the automated generation of test cases. Their experimental results conclude that optimal test cases have been generated from their approach which are more effective than previously used meta-heuristics like GA, ACO and Ant Bee Colony (ABC) algorithm. S.S.B. Lam et al. [33] applied ABC algorithm depending upon edge coverage criteria. They then compared the ABC algorithm with Tabu search, ACO and GA. Result shows that ABC algorithm outperforms these algorithms.
S. Sabharwal et al. [34] suggested a technique, inferred from state and activity diagrams using GA. McMinn and Holcombe [35] explored evolutionary testing of state based programs. They proposed an extended chaining approach in which the problem related with internal variables is solved using hybridization. Wappler and Lammermann [12] proposed an evolutionary algorithm to accomplish the white box testing of object-oriented systems. Tonellea [36] applied GA to generate test cases for unit testing of classes. Doungsa-ard et al. [37] projected an enhanced GA for test case generation from state transition diagram. Chen and Zhong [38] applied the technique of multi-population genetic algorithm to create automated test sequences.
The above literature survey communicates the application of nature-inspired algorithms in the state based testing of SUT. However, each of the above algorithms have certain advantages and disadvantages associated with it. The major findings from the literature survey are as follows: ACO generates repeated plus redundant test sequences and also it may stuck at native optima. Convergence frequency of GA is very sluggish and it also may get stuck at local optima. TS has complications in the quantity of memory needed to avoid getting trapped in native optima. ABC works well only for small sized software.
Thus, irrespective of the extensive research in this field, efficient creation of test paths is still a vulnerable field of study. Here, in this article we offered a new meta-heuristic algorithm, Moth Flame Optimization algorithm to produce optimized and non-redundant test cases.
Methodology used
This section comprises of various nature-inspired techniques used in this paper to create test paths for software applications developed by object-orientation. After that, an overview of the selected object-oriented benchmarks has been provided.
Techniques used
Nature-inspired meta-heuristics have been exploited a lot in approximately past ten years. As we had already discussed in section 2 that previously used meta-heuristics do have certain limitations. Hence, to provide a better solution, we are proposing a new meta-heuristics i.e. Moth Flame Optimization Algorithm. Background concepts of this algorithm will be discussed next.
Moth flame optimization algorithm (MFO)
MFO was primarily given by S. Mirjalili [23]. This is grounded on the ordinary direction finding method of moths in the sky. The basic rules of MFO algorithm are as follows: Moths fly in night by following a static angle from moon. This is termed as transverse gesture of moths. However, these moths got misguided by the artificial lights and get trapped in spiral motion around the light. MFO algorithm basically models this spiral motion of moths toward artificial light.
Thus, a logarithmic spiral is proposed in [23] as follows:
Where, Dp denotes the distance of pth moth from qth, b defines the shape of the spiral and it is a fixed value, t is an arbitrary number in range [−1, 1].
Flames change their sequence according to the best solution in each repetition. Moths, thus modernize their position as per the flame during optimization. Following formula is used in [23] to update the flame no as:
Where, P is the extreme number of flames, p denotes the present iteration number and I shows total number of iterations.
Here in this paper, we are comparing our proposed algorithm with other nature-inspired meta-heuristics. These algorithms will also be discussed in the next sub-section to gain some insights about these.
FA was originally proposed by Xin-She-Yang [39] at Cambridge University. This algorithm is built on the blinking pattern of fireflies and follows below mentioned rules: Individual firefly will be fascinated to other regardless of its gender i.e. they are unisex. Only consideration for attraction is based on the brightness/flashing behavior of firefly. Thus, they will be fascinated towards brighter firefly. If, no more brighter firefly is found, then it will move arbitrarily. Also, one firefly always gets attracted towards the brightest one and if, no such firefly exists, then firefly moves randomly. Intensity of illumination of firefly decreases with distance. This can be expressed as:
Also, if α= 0, then fireflies just move randomly. Randomness thus depends on γ, which is called as absorption coefficient. This brightness factor of firefly can be modelled via an objective function. Lastly, as the distance between two fireflies increases, brightness reduces accordingly. This variation can be formulated as:
Where, β is the degree of brightness, α is the brightness when r = 0 (r is the space amid two fireflies) and γ is the light absorption factor.
ACO was anticipated by M. Dorigo [40]. This algorithm considers the behavior of ant colonies and is modelled as per the below rules: Pheromones are left by each moving ant on the ground. When another ant comes, it senses the pheromone of previous ant, also leaving behind its own pheromone, which increases the pheromone significance of the path in consideration. Thus, every time, a particular path gets highest chance of to be followed upon.
These factors are implemented by Dorigo [40] in the below mentioned way:
1. Construction of the Ant Solution
Probability of movement of an ant from track a to b is:
Where, ζab is the quantity of pheromone on edge (ab), α is the constraint that controls the impact of ζab, η ab is the desirability of edge (ab), and β is the constraint controls the impact of ηab.
2. Updation of Pheromone
Every time a random ant comes, it follows the pheromone of previous ant and also updates the same with her own pheromone in the following manner:
Where, φε (0,1] is the deterioration coefficient of pheromone and ζ0 is the opening value of the pheromone.
In this sub-section, description of Software under Test (SUT) used in this study has been provided. Since, we are concerned about the isolated class, we are projecting our focus towards the applications having single class but a variety of intermediate states. Transition from one state to another helps us in deriving the test cases for that particular class. Following SUT’s has been used in this study:
M. Kamal [42] in his work developed an objectoriented application for Bengali Braille to Text Translator. Braille is a specialized system of writing for visually impaired people. This application accepts the scanned image of braille and converts/translates it to text via pattern recognition. After that, subsequent text correction techniques have been applied to produce the final output.
Shlaer [43] in his research developed a state transition diagram for microwave oven. Oven can be in a waiting state or in an operating state. Also, it may be enabled or disabled depending upon the scenario.
This state transition diagram models one transaction of an ATM system. During a single transaction, ATM can be in idle, waiting or in processing stage.
Proposed moth flame optimization algorithm
This section discusses the proposed MFO algorithm integrated with state transition diagram for the optimization of object-oriented software testing. Here, we are proposing it for an object-oriented application. The steps included in this algorithm have been elaborated as:
Generation of state transition diagram
The very first step of our algorithm is to generate State transition diagram (STD) of the selected SUT’s. STD shows the dynamic flow of control from one state to another. Consider the example of very basic stack class. Its corresponding STD is given in Fig. 1. State Transition Diagram of Stack Class.
Every state of the STD developed in previous step is mapped to a node in the corresponding SG. Also, each and every transition of the STD is mapped to an edge in SG. State graph of the stack class from the STD developed in Fig. 1 is given in Fig. 2. State Graph of Stack Class.
In this step, an adjacency matrix of the previously developed SG is created. This adjacency matrix now represents the matrix of moths. These moths are the search agents and they search for their best position in the space. For our example stack class, generated adjacency matrix is:
Computation of fitness function for moths
As discussed in Section 3.1.1, Flames represents the best obtained position of moths. Thus, moths keep on searching and update every time a better result is found.
Aimed at this, a fitness function need to be developed. Here, we are proposing the fitness function on the basis of total number of nodes and probability of movement of moth from one position to another.
Where, x represents the current node and
From First node, there exists two positions, i.e. at node 2 and 4. Hence, probability will be 0.5. Similarly probability of all the nodes will be calculated and then corresponding fitness values will be calculated as:
For node 5, since it is the end node of state diagram, so a large value is assigned to it. This is called end node affinity [44].
In this step, a motion matrix has been created based on the fitness values calculated above. A software named “
Computation of test paths based on the spiral motion of moths
As discussed in Equation 1, path from each moth/node is calculated. The paths will be calculated as follows:
From Node 1, two paths exists: 1 – >2 and 1 – >4
From Node 2, three paths exists: 2 - >1, 2 - >2 and 2 - >3. Their respective values of spiral motion are 0.7011, 0.396 and 0.6971. Hence path 2 - >2 will be selected. Following the same procedure, next path to be selected will be 2 - >3. So, the current node is now node 3.
From Node 3, paths are: 3 - >2, 3 - >4 and 3 - >5 with values 0.6971, 1.1011 and 1000.6022 respectively. Hence path 3 - >2 will beselected.
The path remaining from node 2 is 2 - >1, as other two has already been selected.
Now from node 1, path selected will be 1 - >4 and finally 4 - >5.
Since, we had reached the end node, so first test path observed will be:
Now, this is the best solution obtained in first iteration, after that as per the Equation 2, number of flames need to be updated. This process will be discussed as: P = number of nodes (in this example, 5); p is the iteration number, so here it will be 2; I, shows the maximum number of iterations, we took it as 10). So the value comes outto be
Since all paths from node 4 has already been covered, we skip this and update the flame number again (now p changes to 3) again value will be 4. In the next iteration (when p is 4), updated value comes out to be 3. So the current node now becomes 3 and path from it 3 - >4 will be chosen. Again no further path from node 4, so again flame number will be updated (p = 5) and the node number comes out to be 3, so the final path i.e. 3 - >5 will be selected. Continue this process for all the 10 iterations. So, finally we have the following three paths generated from MFO:
Paths obtained in previous step have been combined to obtain the independent paths as:
The proposed algorithm has been summarized in the Fig. 3. Flowchart of Proposed MFA.
This section generates the test cases using proposed MFO algorithm integrated with state transition diagram. Figures 4, 5 and 7 shows the STD’s for all the three benchmarks and their corresponding SG’s are given in Figs. 6, 8 and 9. State Transition Diagram of Bengali Braille To Text Translator. State Transition Diagram of Microwave Oven. State Graph f Bengali Braille To Text Translator. State Transition Diagram of ATM Transaction. State Graph of Microwave Oven. State Graph of ATM Transaction.





Generated test paths via firefly algorithm
Test paths for first benchmark using MFO
Test paths generated for second benchmark via MFO
Test paths generated for third benchmark via MFO
In this section, a comparison has been made among the test paths generated by MFO and other meta-heuristics.
Generation of test paths via firefly algorithm
Firefly algorithm has been used in the literature [18] for the generation of test paths of an object-oriented system. Following that process test paths generated for the selected benchmarks has been listed in Table 4.
generation of test paths via ant colony optimization algorithm
Test paths generation via ACO
Test paths generation via ACO
Comparison among MFO, FA and ACO
Table 6 is having three factors for comparison, namely: number of test paths generated by each algorithm, time take by them and redundant percentage of generated test paths.
Redundancy of test paths has been computed as:
On the basis of Table 6, graphical analysis of the discussed algorithms has been provided in Figures 10 and 11. Comparison on the basis of redundant paths (in %). Comparison on the basis of execution time(in ms).

The present research article discusses the problems imposed by object-oriented software testing. MFO algorithm has been proposed aiming the generation of unique and reduced test paths using model based testing. This algorithm has been computed on three benchmark problems having different number of states. Obtained results have been compared with Firefly and Ant Colony Optimization algorithm. Results indicate that MFO algorithm produces reduced test paths when number of states are large i.e MFO is suitable for large sized object-oriented software applications, and for small sized applications ACO generates lesser number of paths and its suits better for that. Secondly, time taken by MFO is much smaller than other algorithms. Again, MFO provides lesser redundancy for large applications and for small applications ACO would be better. Thus on the basis of above observations, we can rank these algorithms as:
MFO>FA>ACO.
ACO>MFO>FA.
As a primary future work, we plan to compare MFO with other meta-heuristics as well on the combination of both small and large sized software.
