Keywords

1 Introduction

The object-oriented program testing is quite complex and still remains a critical research area since decades [1, 2]. The traditional testing approaches are unsuitable for object-oriented testing, thus a different testing practice, model-based testing is followed for deriving test cases [3, 4]. Gradually the Nature inspired algorithms proved their efficiency in proving sub-optimal solutions in various fields of engineering [11], thus researchers started fabricating those nature inspired metaheuristics with the software testing process [5,6,7]. The popular and widely accepted nature inspired metaheuristics mainly includes the evolutionary and swarm based algorithms, starting from the Genetics algorithm to recently popular [19, 20, 22], Bacteria foraging algorithm (BFO), Grey wolf algorithm and the list goes on [11]. Every metaheuristic algorithm has its own specific set of parameters and without proper knowledge of those parameters the algorithms are unable to provide their best results [11]. Keeping in mind those problems arising in metaheuristics due to improper parameters settings, a parameter free algorithm known as teacher learning based algorithm (TLBO) was proposed [12]. The Teacher learning based algorithm includes two stages and it has only two parameters, the size of the population and iteration numbers. Very recently keeping in mind the popularity of the TLBO algorithm, a parameter free algorithm, the JAYA algorithm was introduced, this algorithm is even simpler than the TLBO algorithm, having one stage only [12]. The JAYA algorithm is gradually getting popular, efficiently handling the engineering optimization problems [12], in facial emotion recognition [13], Dimensional optimization [14], economic optimization [15] etc. Thus, keeping in track with the above research findings, this paper proposes a novel improved JAYA algorithm as well as the framework for testing object-oriented programs. The metaheuristic Improved JAYA algorithm is employed in the proposed framework to automatically select a set of test suites to test the object-oriented triangle classification program. Results indicate that the JAYA algorithm provides good exploitation feature to generate test suits. The proposed work targets the following modules for fulfilling the above mentioned objectives,

  • Generation of test suites for testing the feasible test sequences of triangle classification problem using a novel Improved JAYA algorithm.

  • Generation of test suites for testing the feasible test sequences of triangle classification problem using Differential Evolution algorithm.

  • A set of experiments were carried out using the standard triangle classification problem followed by an exhaustive comparison between the metaheuristics i.e. JAYA, Differential Evolution and improved JAYA algorithms.

The remaining sections of this work are systematized as follows, the Sect. 2 conveys a detailed explanation of the classical JAYA algorithm, the novel improved JAYA algorithm and their specific set of parameters; Sect. 3 explains the suggested framework for the generation of feasible test suits, Sect. 4 includes the extensive experimental set up Sect. 5 provides experimental results and discussions with the detailed statistical analysis. Lastly, the conclusions and prospective future directions are projected in Sect. 6.

2 Proposed Algorithm

The metaheuristic Jaya algorithm [16] was introduced by Venkata Rao [14], it’s a very simple and parameter free algorithm that has been already used for numerous optimization problems in diverse domains of continuous space. In this paper an improved Jaya algorithm with improved exploration and convergence speed is proposed by adding an efficient mutation scheme the conventional JAYA algorithm. This improved Jaya algorithm was applied in one research work for automatic ear image enhancement of the ear biometric system [18]. It was noticed that the improved JAYA algorithm show better performance for image enhancement in comparison to other two metaheuristics i.e. PSO and Differential Evolution based image enhancement techniques. Therefore, this paper used the Improved JAYA algorithm as well as the Conventional JAYA algorithm and compared the performance of the respective algorithms with widely popular Differential evolution algorithm, in terms of test data generation and computational speed, for the first time in the field of object-oriented testing.

2.1 JAYA Algorithm

The metaheuristic JAYA algorithm is a parameter free optimization algorithm The principle of the algorithm is to obtain good solutions avoiding bad solutions. Iteration-wise updating each solution is mathematically expressed in [18] as follows:

$$ \begin{array}{*{20}l} {X_{i,j} \left( {g + 1} \right) = X_{i,j} \left( g \right) + r_{1,i,j} *\left( {X_{i,best} \left( g \right) - \left| {X_{i,j} \left( g \right)} \right|} \right) - r_{2,i,j} } \hfill \\ {*\,\left( {X_{i,worst} \left( g \right) - \left| {X_{i,j} \left( g \right)} \right|} \right)} \hfill \\ \end{array} $$
(1)

where \(X_{i,j} \left( g \right)\) is the jth parameter value for ith solution at g iteration. \(X_{i,best} \left( g \right)\) is the value of the best solution for ith parameter at gth iteration and \(X_{i,worst} \left( g \right)\) is the value of the ith parameter for the worst solution at the same gth iteration. Two random numbers \(r_{1,i,j } {\text{are}}\) \(r_{2,i,j}\) generated in the range of [0, 1] at iteration g, \(X_{i,j} \left( {g + 1} \right)\) hold the updated values of the jth parameter for ith candidate solution in \(\left( {g + 1} \right).\) The neighborhood positions are exploited and candidate solutions are continuously upgraded in subsequent iteration using Eq. (1) to lead the convergence towards global solution. The two random numbers \(r_{1,i,j}\) and \(r_{2,i,j}\) help in improving the searching capability of Jaya algorithm. Initially the candidate solutions are updated at current iteration n, then based on fitness values the best individual solutions are updated after comparing the current solution \(X_j \left( g \right)\) and updated solution \(X_j \left( {g + 1} \right)\) for the next iteration \(\left( {g + 1} \right)\) as described in [22]:

$$ X_j \left( {g + 1} \right) = \left\{ {\begin{array}{*{20}c} {X_j \left( g \right), if f\left( {X_j \left( g \right)} \right) > f\left( {X_j \left( {g + 1} \right)} \right)} \\ {X_j \left( {g + 1} \right), Otherwise} \\ \end{array} } \right. $$
(2)

Thus the solutions of subsequent iteration are better than the corresponding solutions of current iteration. The modified fitness values of the candidate solutions are the inputs for next iteration. In this manner the algorithm always converges towards best solution.

2.2 Improved JAYA Algorithm

In order to improve convergence rate, a mutation operator has been introduced with Jaya algorithm and the proposed technique is known as an improved version of Jaya algorithm (IJA). It is revealed in [18], that the Differential evolution metaheuristic algorithm shows better performance than the Particle Swarm Optimization algorithm in robust performance and faster convergence towards global optima. Therefore the mutation operator of the Differential Evolution algorithm has been used in the JAYA algorithm to add diversification. In order to establish balance between the exploitation and exploration strategies an adaptive mutation operator is introduced. Mathematically the mutation operator is defined in the following Eq. (3),

$$ X_j \left( {g + 1} \right) = X_{r_1 } \left( g \right) + F*\left( {X_{r_2 } \left( g \right) - X_{r_3 } \left( g \right)} \right) $$
(3)

here \({\text{j}} \in \left\{ {1, \ldots ,{\text{K}}} \right\}\), jth candidate solution of the population of size K. Correspondingly, \({\text{r}}_1\), \({\text{r}}_2\), and \({\text{r}}_3\) are the indices of the candidate solutions \(\left\{ {1, \ldots ,{\text{K}}} \right\}.\) Here, F is the scaling factor used to avoid the population stagnation and to control the difference vector in the mutation operation, it is in the range of \(\left[ {0,\,1} \right].\) The an adaptive scaling factor has been used here is described as in Eq. (4).

$$ F = 0.8 + rand\,*\,((G_{max} - g)/G_{max} ) $$
(4)

where g and \(G_{max}\) are the current iteration and maximum number of iterations respectively. The rate of mutation in Eq. (3) can also be evaluated adaptively, and when in this manner a random real number, greater than the rate of mutation. is generated then the mutation operation will be performed.

$$ rand \ge \left( {1 - \frac{g}{{G_{max} }}} \right) $$
(5)

The rate of mutation fluctuates between 1 to 0, through initial iteration to a maximum number of iterations.

3 Projected Framework

This work proposes a framework; Fig. 1 for testing object oriented programs using the UML state machine model of the triangle classification problem and a novel improved JAYA algorithm. Initially the UML state machine model; Fig. 2 is developed and then it is converted to state chart graph. After that the nodes and edges are assigned weights [1, 2]. Then the SCG graph is traversed using the DFS algorithm in order to find out the total path cost and the feasible paths. The fitness function of the feasible paths is the total path weight [1, 2]. The JAYA, improved JAYA and DE metaheuristic algorithms are applied to generate test suits, fulfilling the transition coverage criteria.

Fig. 1.
figure 1

Projected framework for model based testing

Fig. 2.
figure 2

The UML state machine model

4 Experiments

First of all, a UML state machine model was generated using ArgoUML, for the example problem, i.e., classification of triangles. After that metaheuristic JAYA, improved JAYA and DE algorithms, are used to generate test suits automatically using Matlab R2016b.

The fitness function of the problem is the total path weights of respective feasible paths, it is a maximization problem. The range of data variation is –10000 to 10000. To verify the exploitation and exploration capabilities of the metaheuristic algorithms, i.e. JAYA, Improved JAYA and DE a number of experiments were conducted with varying populations (10, 20, 30) and fixed generation (10), and then with varying generations (20, 30, 50) and fixed populations (10). After that again the different combination of generation, 20, 30 and population 50, 100 were taken to thoroughly test the time complexity and exploration capabilities of the algorithms.

  • Case study

    Triangle classification problem is the benchmark problem in software testing domain [1, 2], specifically test data generation [3, 9]. The distinctive attribute of the problem is, it needs separate groups of test data to test first the triangle properties and then the types of triangles like scalene, equilateral and isosceles. [1]. This problem is selected as the case study to automatically generate test suites using Improved JAYA, DE and JAYA algorithms. This example problem has four feasible path sequences and six states (S1, S2, S3, S4, S5, S6). The statistical results after using JAYA, DE, and improved JAYA algorithms are depicted in Table 2 and Table 3. The test suits generated for respective path sequences using improved JAYA, algorithm are represented in Fig. 3 and Fig. 4 respectively. The Fig. 5 and Fig. 6 are showing the test suites generated by all the three algorithms i.e., JAYA, DE and Improved JAYA. The Table 2 and Table 3, show the detailed statistical analysis of the test suits generated using the proposed framework and metaheuristic algorithms. In these tables the minimum and maximum point outs the lower number of test cases and maximum number of test cases generation for the individual path. The maximum point outs the upper bound in test cases generation for a particular path. The table shows a minimum value to be zero when in at least one of the executions no data is available for covering a path, in the same way if the maximum value provided is zero then it signifies no data is generated at all for testing that path. Lastly the Table 4 shows the execution time of the three algorithms (Table 1).

    Table 1. Test sequences of the triangle classification problem

5 Results and Discussions

The aim of conducting the experiments with varying generations and populations was to figure out the exploration and exploitation capabilities of the algorithms. The detailed statistical analysis of the results like max, min, and average performance of the algorithms along with standard deviations were recorded in Table 2 and Table 3. The worst-case analysis of the algorithms shows that for path sequence 3, the critical path of the problem only improved JAYA achieved the best results, with large population size. The same trend is observed in average case analysis too. In most of the iterations the JAYA, improved JAYA, DE algorithms generated no data for path sequence2 and 3 whereas the Improved JAYA generated test data uniformly for every path sequence in case of maximum. The Fig. 3(a, b, c) depicts the test cases generated by improved JAYA with generation 10 and population variation 10, 20, 30, similarly Fig. 4(a, b, c) shows the test cases generated by improved JAYA with generation 20, 30,50 and population variation 10. In the next experiment the results of all the three algorithms for generating all four paths are recorded in Table 3 by varying the population to 10, 20, 50 and keeping the number of generations fixed at 10. The best, worst, and average case analysis of the results along with statistical analysis is provided in Table 3. Here it is observed that for path sequence 3, all of the three algorithms are providing almost zero results for best case in population 10 and 20, the DE is giving best result for only path sequence1 and JAYA for path sequence4 in all the three generations. The worst-case analysis shows that DE is giving best results for path sequence1, JAYA for path sequence 4, Improved JAYA for path sequence2 and 3. The average case analysis shows the same results. The Fig. 5(a, b, c) depicts the test cases generated by all the three algorithms at generation fixed at 10 and population size (30, 50,100). The Fig. 6(a, b, c) show the generated test cases, at generation fixed at 20 and population size (30, 50,100). When the results of Table 2, and Table 3 were compared, it was clear that the JAYA, DE and Improved JAYA, are not able to provide adequate number of test suits, when the population size and generations are small. The improved JAYA algorithm generated stable and uniform test suits, only when the population size is large.

Table 2. The statistics for test suite generation using Jaya, De, Improved Jaya with population size (30) & generation number (10, 20, 30)
Table 3. The statistics for test suite generation using Jaya, De, Improved Jaya with population size (10, 20, 50) & generation number (10)
Fig. 3.
figure 3

Test suites using Improved Jaya (A, B, C), with generations (10) and population size 10, 20, 30

Fig. 4.
figure 4

Test suite using Improved Jaya (A, B, C), with fixed population 10 and variations in generations 20, 30, 50

Fig. 5.
figure 5

Test suites generation using Jaya, De and Improved Jaya (A, B, C), with generations 10 and population size 30, 50, 100

Fig. 6.
figure 6

Test suite generation using Jaya, De and Improved Jaya (A, B, C), with fixed number of generations (20) and variations in population size (30, 50, 100)

Table 4. Average run time (in seconds) for generation of test suits based on JAYA, DE, and Improved JAYA with generation 10 and population size 50.

6 Conclusions

The testing of object-oriented programs, particularly the test suite generation from design artifacts is a very difficult task. This work provided a novel Improved JAYA algorithm-based framework to generate optimized test suits. The optimal test suites were generated using the proposed framework and UML behavioral model. The proposed framework efficiently generated uniform test suits for all the feasible paths. The obtained simulation results ensured the efficiency of the improved JAYA algorithm over the performances of the individual JAYA and DE algorithm in terms of the exploration and exploitation capabilities. The framework can be further improved by using the hybrid version of this metaheuristic JAYA algorithm along with different UML diagrams.