Target-based test path prioritization for UML activity diagram using weight assignment methods

Received Apr 9, 2020 Revised Jun 11, 2020 Accepted Jun 28, 2020 The benefit of exploratory testing and ad hoc testing by tester’s experience is that crucial bugs are found quickly. Regression testing and test case prioritization are important processes of software testing when software functions have been changed. We propose a test path prioritization method to generate a sequence of test paths that would match the testers’ interests and focuses on the target area of interest or on the changed area. We generate test paths form the activity diagrams and survey the test path prioritization from testers. We define node and edge weight to the symbols of activity diagrams by applying Time management, Pareto, Buffett, Binary, and Bipolar method. Then we propose a test path score equation to prioritize test paths. We also propose evaluation methods i.e., the difference and the similarity of test path prioritization to testers’ interests. Our proposed method had the least average of the difference and the most average of the similarity compare with the tester’s prioritization of test paths. The Bipolar method was the most suitable for assigning weights to match test path rank by the tester. Our proposed method also has given the affected path by changing area higher priority than the other test path.

Activity node 1) weight=1 [5,11,15,16] 2) weight=4, if the node was inter-depended activity [16] 3) weight=6, if the node was control node [16] Normal edge 1) weight=1 [12] 2) weight=2 [22] Edge passed the decision node 1) weight=total weight of all outgoing edges must be 1 [12] 2) based on 80/20 rule [22] edge weight=4 for the true edge of the decision node edge weight=1 for the false edge of the decision node Decision node 1) weight=2 [11,16] 2) weight=4 [5,15] Merge node 1) weight=2 [11] 2) weight=3 [5,15], Fork-join node 1) fork weight=2, join weight=2 [5,15] 2) fork weight=3, join weight=3 [11] 3) fork weight=5, join weight=3 [16] Final node  1) weight=0 [15]  Weight score Calculation methods for test path score Node 1) sum of all node weights, where the weights of the nodes were assigned according to the type of symbols (see Table 1) [5,15,16] 2) sum of all node weights, where the weight of the first node equals 1 and the weight of the next node will have 1 added until the last node [18,23,24] 3) sum of all node weights, where the weights of the nodes were assigned using Stack-based weight approach and the Basic IF Model [14,17] 4) the number of nodes+sum of node weights+the number of predicate nodes+the number of logical condition nodes [13] Edge 1) sum of all edge weights, where the weights of the edges were assigned according to the type of edges (see Table 1) [12] Node and edge 1) sum of all node weights+sum of all edge weights, where the weights of the nodes were assigned according to the type of symbols (see Table 1) and the weights of the edges were assigned by the number of incoming dependencies of predecessor node multiplied by the number of outgoing dependencies of the successor node [11] 2) sum of all node weights+sum of all edge weights, where the weights of the nodes were assigned by using backward slices approach and the weights of the edges were assigned according to the type of edges (see Table 1) [22] Kaur et al. [13] proposed the prioritization of test paths descended from UML activity diagram by using complexity of the path as follows. First, the activity diagram was transformed into a control flow graph. Second, the test paths were generated from the control flow graph using the depth first search. When it found fork nodes, it would select one representative path by using breadth first search to get unique independent paths. Third, assigning a weight to each node IF(N) was by the number of incoming edges to the node FANIN(N) multiplied by the number of outgoing edges from that node FANOUT(N), using (1). Each test path score W p was found by summing node weights W i in the set T p and n was the number of nodes, using (2). Fourth, the complexity C of test path was calculated using (3) by gathering the values of the number of nodes (N p ), the score of test path (W p ), the number of predicate nodes (P p ), and the number of logical conditions (C p ). And finally, the test paths would be prioritized from the highest path complexity to the lowest path complexity.
Wang et al. [15] proposed test path prioritization derived from UML activity diagram as follows. First, the activity diagram was transformed into a control flow graph. Second, the test paths were generated by the depth first search. Third, the weight of each node was assigned based on the type of symbols in UML activity diagram. If the node was an initial node or an end node, it was assigned 0. If the node was an activity node, it was assigned 4. If the node was a fork node or a join node, it was assigned 2. If the node was a merge node, it was assigned 3. Next, each test path score f(x) was the sum of node weights W i on that test path and n was the number of nodes in the chromosome C in the population P, using (4). Finally, this research prioritized the test paths from the highest score. If two test paths had the same score, it would randomly select the test path priority order between these.
Mahali and Acharya [16] proposed the prioritization of test paths using UML activity diagram and evolutionary algorithm as follows. First, the activity diagram was transformed into an activity graph and all test paths were created. Second, each node was assigned a weight based on the symbols of UML activity diagram. If the node was a normal activity node, it was assigned 1. If the node was a decision node, it was assigned 2. If the node was an activity of one thread depends on each other, it was assigned 3. If the all activity node was within the decision symbol or the fork-join symbol, it was assigned 4. If the node was a fork node, it was assigned 5. If the node was a control node, it was assigned 6. Third, the test path score F(x) was the sum of node weights C ri in that test path, using (5). This research prioritized the importance of test paths from the highest to the lowest path score.
Jena et al. [22] proposed test path generation and prioritization as follows. First, the interaction overview diagram was converted into an interaction graph. The sequence diagram was transformed into message sequence dependency graph. And then, the two graphs were combined into a sequence interaction graph. Second, all possible test paths were created from the graph by using depth first search. Third, the weights were set to each node of the graph according to the number of nodes affected by the current node, determined with backward slicing. The weight of normal edges was 2. The edge from a decision node was assigned by using 80/20 rule and weight 4 was assigned to the true valued edge (80%) while weight 1 was assigned to the false valued edge (20%). Fourth, the score of a path was the sum of node weights plus the sum of edge weights along the test path, using (6). Finally, this study prioritized the test paths from the highest score to the lowest score.

RESEARCH METHOD
This study aimed to prioritize the importance of the test paths according to the target area of interest, the changed area, and the test paths prioritized by the testers. The steps are as follows.

Define the criteria to select the UML activity diagram
The UML activity diagrams were selected according to the following criteria: the UML activity diagrams that were frequently used in research studies on software testing, the UML activity diagrams that were used in daily lives, the UML activity diagrams that were easy to understand, and the UML activity diagrams that had various control flows affecting the test path selection. The selection of UML activity diagrams depended on the control structure. Each UML activity diagram selected for this study had different control structures. As a result, the selected four UML activity diagrams for the experiment were as follows i.e., ATM Withdraw activity diagram [27], Shipping Order System activity diagram [13], Buy Beverage from Vending Machine activity diagram [11], and Mileage Purchase Web Portal activity diagram [28].
The ATM Withdraw activity diagram, applied from Boghdady et al. [27], comprises many types of control structures such as selection control structures consisting of one-way selection, two-way selection, and nested selection; and a one-way selection control structure within fork-join structures as shown in Figure 1. The Shipping Order System activity diagram, applied from Kaur et al. [13], comprises a fork-join structure with no control structure inside, selection control structure consisting of two-way selection, but there is no iteration control structure as shown in Figure 2. The Vending Machine activity diagram, applied from Sapna and Mohanty [11], which comprises two iteration control structures with pre-test loop. This diagram does not have the fork-join structure as shown in Figure 3. The Mileage Purchase activity diagram, applied from Paiboonkasemsut and Limpiyakorn [28], comprises selection control structures consisting of two-way selection and nested selection, and there is a fork-join structure. This diagram does not have an iteration control structure as shown in Figure 4.

Transform the UML activity diagram to an activity flow graph
The four activity diagrams were transformed to an activity flow graph. For the concurrence region, a questionnaire-based survey for test path by testers' interest, 65 professional software testers show that the path must be traversed from left-to-right. Each thread is listed from the activity of top-level to activity of low level according to the depth first search method.
The ATM Withdraw activity diagram was transformed into an activity flow graph, which is a directed graph. Each node represents the symbols of activity diagram and each edge represents the flow in the activity diagram. The activity flow graph of ATM Withdraw activity diagram is depicted in Figure 5, where I is the initial node, F is the final node, di is a decision node, fi is a fork node, and ji is a join node. The Shipping Order System activity diagram, the Vending Machine activity diagram, and the Mileage Purchase activity diagram were transformed into an activity flow graph, depicted in Figures 6-8 respectively.

Questionnaire-based survey for test path prioritization by testers' interest
The four activity diagrams in section 2.1 were used to generate test paths in each activity diagram. Then, the test paths were given to 65 professional software testers to prioritize them by importance according to their interests to create a baseline for comparisons. The data obtained were analyzed for prioritization frequencies of the test paths. The survey results on the prioritization of the test paths in ATM withdraw, Shipping order system, Vending machine, and Mileage purchase activity diagram according to the testers' interests are summarized in Tables 3-6 respectively. In Table 3, the ATM withdraw activity diagram has generated 14 test paths (P1 to P14). All 65 testers will assign a path (row) to rank the importance of the test according to their interest by arranging them in order 1-14 (columns). The highest value depicted in  The frequency distribution of ranking 1 2 3 4 5 6 7 8 9 10 11 12 13 14  P1 I  The frequency distribution of ranking  I-1-d1-2-d2-3-4-5-8-  The frequency distribution of ranking

Propose approaches to test path prioritization
The weight assignments in the activity flow graph transformed from the UML activity diagram are the topic of this section and then the scores of the test paths are calculated. The activity flow graph consists of nodes and edges as shown in Figures 5, 6, 7, and 8. The nodes and edges have assigned weights as follows.

Define weights of the nodes in the activity flow graph
Initial node and final node presented the flow start and the final step are assigned 0. Merge, fork, and join node which are the control node that deputed flow of the program are assigned 0. Decision node is assigned 0, we use several methods to consider the edge weights for the decision node instead. Activity node contained the program statement is assigned 1.

Define weights of the edges in the activity flow graph
Normal edge is assigned 1. Edge of decision node is based on the work breakdown structure. It can have more than 2 edges but the total weight of True value and false value is 100%. The True edge is assigned more weight than the false edge. In this research, the weight of an edge is based on either time management method, Pareto method, Buffett method, Binary method, or Bipolar method as shown in Table 7. The total weight of edges of a decision node is 5. The Time management, a 70/30 rule is applied to assign weights to edges from decision node [29]. For 70% the True edge weight assigned is 3.5, and 30% the false edge weight assigned is 1.5. The Pareto, an 80/20 rule is applied to assign weights to edges from the decision node [22,29]. For 80% the True edge weight assigned is 4 and 20% the false edge weight assigned is 1. The Buffett, a 90/10 rule is applied to assign weights to edges from a decision node [29]. For 90% the True edge weight assigned is 4.5, and 10% the false edge weight assigned is 0.5. The Binary, a 100/0 rule is applied to assign weights to edges from the decision node. For 100% the True edge weight assigned is 5 and 0% the false edge weight assigned is 0. The Bipolar, a 100/-100 rule is applied to assign weights to edges from the decision node. For 100% the True edge weight assigned is 5 and -100% the false edge weight assigned is -5.

Calculating scores and prioritizing for test paths
The test paths from each activity diagram were given scores Score p to prioritize their importance. W e is an edge weight in the test path and E is the number of edges in the test path. W n is the weight of the test path (sum of node weights in test path) and N is the number of nodes in the test path. The score of a test path Score p is calculated by (7), and the test paths are prioritized according to their scores in descending order.

Comparing computed results on prioritization of test paths with the survey results on the testers' prioritization of test paths
The objective of the proposed approach is to rank the test paths the same as the testers' interests. In this section, the difference and the similarity between test path prioritization by the proposed methods and the subjective test path prioritization according to the testers' interests will be evaluated.

The calculation of the difference to subjective prioritization of the test paths
The difference Diff(T,R) between test path rank by the proposed methods (R) and the subjective test path prioritization according to the testers' interests (T) is quantified in this section. The difference between test path prioritization can be calculated by (8) where P is the number of test paths in activity flow graph. The value of difference Diff(T,R) is between 0 and 1, the ideal value for Diff(T,R) is 0. D p is the difference of a T-R pair of the test path. T p is the test path rank according to the testers' interests, and R p is test path rank

The calculation of the similarity to subjective prioritization of the test paths
The similarity Sim(T,R) between test path rank by the proposed methods (R) and the subjective test path prioritization according to the testers' interests (T) is quantified in this section. The similarity between test path prioritization can be calculated by (9), where P is the number of test paths in activity flow graph. The value of similarity Sim(T,R) is between 0 and 1, the ideal value for Sim(T,R) is 1. S p is the similarity of a T-R pair of the test path. T p is the test path rank according to the testers' interests, and R p is test path rank by a proposed algorithmic method. If R p is less than T p , this means that rank by the proposed method is not too late for testing, the similarity of the test path is 1. If R p is equal to T p , this means that the proposed method can match the test path rank to the testers' interests, the similarity of the test path is doubly rewarded. If R p is more than T p , this means that rank by the proposed method is too late for testing, the similarity of the test path is 0. MaxSim is the maximum sum of the similarity of T-R pair of all paths.

RESULTS AND DISCUSSIONS
The study assessed the proposed weight assignment methods i.e. node weights and edge weights applying with Time management method, Pareto method, Buffett method, Binary method, and Bipolar method. In the experiment, the test paths from four UML activity diagrams (as described in section 2.3) were prioritized and compared with prior researches.

The results of test path prioritization
The prioritizations of test paths from the activity flow graphs were obtained by assigning weights using five proposed methods: calculating the scores for the test paths by (7), calculating the difference and the similarity to subjective prioritization of the test paths according to the testers' interests by (8) and (9), respectively. If two test paths had the same score, it would assign the same rank value and the next number(s) will be skipped. The results of test path prioritization for ATM Withdraw activity flow graph are shown in Table 8, for Shipping Order System activity flow graph are shown in Table 9, for Vending Machine activity flow graph are shown in Table 10, and for Mileage Purchase activity flow graph are shown in Table 11. In all four tables, "Early" means the number of test paths that rank by the proposed method is earlier than rank by the tester. "Late" means the number of test paths that rank by the proposed method is later than rank by the tester. "Equal" means the proposed method can match the test path rank to the testers' interests.

Comparison of test path prioritization by the proposed algorithmic method and testers' interests
On the evaluation of our proposed methods, the average of the difference and similarity values of all proposed methods were compared with prior published studies i.e., Kaur et al. [13], Wang et al. [15], Mahali and Acharya [16], and Jena et al. [22] with weight assignment as described in Table 1 and test path score calculation as described in Table 2.

Comparison of the difference to subjective prioritization of the test paths
On comparing five proposed algorithmic method with prior published studies, the difference values of all proposed methods were less (better) than those in the prior published studies for ATM Withdraw activity diagram, Shipping Order System activity diagram, and Mileage Purchase activity diagram as shown in Table 12. The Bipolar method had the least average of the difference value. Moreover, in comparing every average difference score of the proposed methods with the results from prior published studies, they performed better.

Comparison of the similarity to subjective prioritization of the test paths
The experimental results show the similarity values of all proposed methods were more (better) than those in the prior published studies for ATM Withdraw activity diagram, shipping order system activity diagram, and Mileage Purchase activity diagram as shown in Table 13. The Bipolar method had the most average of the similarity value. Moreover, in comparing every average similarity score of the proposed methods with the results from prior published studies, they performed better.

TARGET-BASED TEST PATH PRIORITIZATION
The enhancement of our proposed methods was the test path prioritization with the target area or changed area. To prioritize by the importance of the target area or of the changed area, the test paths for which the testers focused on the target area were prioritized by adding weight to those paths. As shown in (10), WT is the target weight. In case that the path composes of the target areas specified by the tester, WT is the maximum length of all test paths otherwise the WT value is 0. For example, now consider the test paths in the ATM Withdraw activity flow graph as shown in Figure 5, the testers were interested in the target area of node 9, so the test paths that passed through node 9 (P5, P6, P7, P8, P9, P10) were prioritized higher than the other test paths, as shown in Table 14.   12  12  11  11  11  11  11  11  11  11  P12  11  11  11  11  12  12  12  12  13  13  P13  14  14  14  14  14  14  13  13  12  12  P14  13  13  13  13  13  13  14  14  14 14 Note: w/o stands for "without" and w/ stands for "with".