Test Cases Generation for Object-oriented Software from Decision Slicing of UML Activity Diagram

Software testing is an integral part of the software development life cycle. Design of good test cases is a key challenge in software testing. Test cases can be designed from different artifacts like requirements, design and software code. In Software engineering, different UML diagrams are


INTRODUCTION
Software testing is a creative and challenging part of the software development life cycle. Quality and reliability of the developed software products is ensured with the help of software testing. Software testing cost generally depends on the how efficiently testing is performed. There are mainly three activities in test process: test cases generation, test case execution and test evaluation. Generation of test cases is most critical activity. A test case is the triplet [I, S, O] where I is input data, S is the state of the system and O is expected output [1][2].
There are mainly two approaches of software testing namely: white box and black box. In white box testing, there is need to know internal details of programs and in black box testing test cases are generated with the requirement specification documents and internal structure of program is not considered. In black box testing, test cases are designed with consideration of the functionality of the software system. Model based testing is a kind of black box testing which is used to find bugs earlier in the software development life cycle. In model based testing expected models which capture requirements of the software under test are created and a test tool is used to automatically derive the test cases from the designed models [3].
Large systems are more complex to test. To reduce the development and testing costs of modern software, software engineers usually advocate the use of object-oriented analysis and design paradigm [4]. Testing object oriented system with the code is tedious and complex task. Object Management Group (OMG) [5] introduced the standardized Modeling Language called Unified Modeling Language [6] to facilitate the use of standardized notation for objectoriented analysis and design. Design models are used by tester to test the object oriented software. Activity diagram is designed with higher level of abstraction so it contains less information in comparison to other UML diagrams like sequence diagram, class diagram. Software developers are heavily using models in the development of the software products [7]. Information required for testing can be generated by simple processing of these models. Testing an executable form of software artifacts involve three phases [8] namely: design of test cases; execute the test cases with the executable software artifacts; analysis the behavior of the results. Test adequacy criteria are proposed by researchers to check up to how much extent a property must be tested [9].
Unified Modeling Language is used for creating the software blueprints. It consists of different notations to support design and analysis of the object-oriented software development. It facilitates to use different diagrams to present static and dynamic views of the systems. Activity diagram focuses on the flow of behavior of a system [10]. Different UML diagrams like class diagram, use case diagram and activity diagram are used to represent system at different level of abstraction. Activity diagram is like flow chart but it is more expressive than flow chart. Sequential or concurrent control flow can be represented by an activity diagram. UML activity diagram is used by several researchers as initial specification of the system for generation of test cases [11][12][13].
Large and complex software can be decomposed into manageable pieces of code to easily handle the complex software and there are accurate dependency exists among different pieces of the software. Program slicing techniques are used to handle the complexity of programs which arises due to large size of programs. Program slices extracts are those statements of the programs which are relevant to a particular computation [14]. Dynamic slices are often smaller size than static slices as it includes only those statements of program which are executed for particular input data.
Program slicing techniques are used in different aspects of the software development like debugging [15], software maintenance [16], software measurement [17] and software testing [18]. In the present work, authors used a new slice method of UML activity diagram called decision slice and generated test cases for each activity path. Test data corresponding each activity path is generated using an iterative method of numerical analysis. Iterative method is used in [19] for generating tests data in the context of program code. In our approach iterative method is used at design level for test cases generation. The rest of the paper is organized as follows: Section 2 of the paper describes the UML activity diagram and iterative method used for test cases generation. Section 3 presents the methodology used for test cases generation. A case study of automatic ticket vending machine is presented in section 4. In section 5 a comparative study of proposed technique with other techniques in literature is given and finally in section 6 authors concluded the work.

UML Activity Diagram
In the current work, UML activity diagram is used to represent the functionality of the system. Activity diagram contains mainly two types of nodes namely action nodes and control nodes. Action nodes contains Activity, Action, SendSignal and AcceptEvent while Control nodes contains InitialNode, FinalNode, Decision, Merge, Fork and Join. There are several levels of activity modeling: Basic, Intermediate, Complete and Structured Complete and extra structure activities in UML 2.1 superstructure [20]. Test scenarios are used to check whether all business process related to the software are tested end to end. Test cases and test scenarios are often used by Software tester synonymously [21]. An activity diagram(AD) as defined in [22] is based on seven tuple described below: AD= (A, T, F, J, R, a i , a f ) where A is finite set of activities a 0 , a 1 ,… .,a n , representing nodes, T is finite set of transitions t 0 , t 1 ,…..,t n representing (edges), F is finite set of forks f 0 ,f 1 ,…,f n . , J is finite set of join j 0 , j 1 ,….,j n . and R ⊆ (A X T) U (T X A) is the flow relation, a 0 is initial activity node and a f is final activity node.

Stationary Iterative Method
In numerical analysis iterative methods are used to generate improved approximate solution for a class of problems [23]. There is a termination criteria defined to solve the problem with iterative method. Initial data is guessed to find out the solution of the system of equations and successively approximate solutions which are closer to the results are generated.
These methods are also called relaxation methods. These methods use the error in the result to approximate the solution and error in the result is called residual. Stationary iterative methods use an operator to approximate the solution of linear system.
Let an equation ax+by+cz+d=0 (1) and its approximate solution is (x 0 ,y 0 ,z 0 ), then substituting the values of (x 0 , y 0 , z 0 ) in the equation we will get a positive value residual.
In the present technique of test cases generation from UML activity diagram, authors used this iterative method. For formulating the problem of test cases generation from activity diagram as an iterative method, we derived the decision functions corresponding to each decision nodes of the activity diagram. These decision functions are used to derive the system of equations. Here initial solutions of inputs are guessed and increments in the initial values are computed by solving the equations.

PROPOSED METHODOLOGY
The steps in the proposed methodology are described below: Then decision function will be F i : a i x+b i y+c i z+e i For computing the coefficients a i , b i and c i with respect to their variables evaluate the decision function at the current input I k =(i 1 ,….i j ,….i m ) and at I k +(0,…..,∆i j ,…0) and compute the divided difference by using the formula given below F( I k +(0,…., ∆i j ,…,0)-F( I k )/ ∆i j This gives the coefficient of i j in the linear function for the decision function F corresponding to node i in P. Similarly other coefficients are computed.
Decision functions are also formulated from values of each decision nodes on activity path; If a decision nodes have no input variables then decision function for that decision node will contain one Boolean variable with 0 for false and 1 for true value of the function.

Formulate the linear equations from decision nodes.
Convert linear functions into inequalities. For conversion of linear functions into inequalities we choose >,= and < operators. If a decision node on an activity path needs to be true for traversal of that path then relational operator will be same as used in decision node else it will be reverse of the decisional nodes.
Compute decision residuals. Decision residual of a decision node for an input is the value of decision function computed by executing its decision slice at that input; Then apply the relaxation technique and formulate the inequalities of increment of the input variables and convert these into equations and solve these equations. On solving these equations we get the increment values which will give the next input values. This process of iteration continues till we get the values which traverse the activity path.

A CASE STUDY OF TICKET PURCHASING FROM AUTOMATIC TICKET VENDING MACHINE
In the present section UML activity diagram is designed for ticket purchasing from automatic ticket vending machine and test cases are generated using presented approach. Fig. 1 presents UML activity diagram for purchasing tickets from ticket vending machine. There are three partitions which are Passenger, Ticket Vending Machine and Bank. Passenger can perform different activities. Passenger selects the ticket types and destination of travel which inputs the price of ticket. Then passenger selects number of ticket types (n). Then ticket vending machine computes the total amount and displays the total fare. Then machine process for payment. Ticket vending machine accepts money either by card or cash. If passenger pays with card then bank is used for authorization of payment and ticket is issued. If passenger inserts cash then machine calculates the difference between inserted money and total fare. If money inserted is less than the total fare then a message of insufficient amount is displayed. If difference between total fare and money inserted is 0 then ticket is issued and money inserted is more than the total fare then machine issues ticket along with the returned money. Fig. 2 represents the activity flow graph of activity diagram given in Fig. 1. In Fig. 1 there are 21 different constructs like start, end node, activities, fork, join and decision node these are converted into nodes of activity flow graph. Nodes 8, 13 and 15 represent decision nodes of activity diagram. Nodes 17 and 20 represent the fork and join nodes of activity diagram respectively. Activity paths from activity flow graph are generated by traversal the graph in depth first search manner and there is a fork and join node then node between them are traversed in breadth first search manner which is activity path4. Generated activity paths are given below: Activity Path1 1-2-3-4-5-6-7-8-9-16-21 Activity Path2 1-2-3-4-5-6-7-8-9-10-12-13-

Derivation of Decision Functions
Let x for the decision nodes which do not contains constraints and values of x are 0 or 1.
Activity path 2 contains three decision nodes 8, 13 and 15. For each decision nodes presented in the corresponding activity path, we identify the input variables which will affect the outcome of the decision node. It is given by ID( DN 2 , P)=(p, n, a) ID( DN 3 , P)=(p, n, a) For each decision nodes available in the corresponding activity path authors formulated the linear equations. Activity path2 has three decision nodes so there will be three equations: F 2 =a 2 p+b 2 n+c 2 a+e 2 (9) Here equation 8 represents decision node with no input variables so it takes the form of equation 11; We select x=1 for traversal of activity path2.
Decision functions corresponding equations 9 and 10 are formulated from values of corresponding decision nodes on activity path and are given by equations; Let I 0 =(p, n, a)=(100, 2, 220) then input will be (x, p, n, a)=(1, 100, 2, 220), this will not traverse the activity path2.
Then next input is obtained using the above iterative method: We take increment ∆p=2 and computed the values of F 1 at I 0 .
Then divided difference F 1 (p 0 +∆p,n 0 ,a 0 )-F 1 (p 0 ,n 0 ,a 0 )/∆p is calculated which gives the value of a 1 a 1= (16)(17)(18)(19)(20) Similarly other values are calculated and recorded in Table 1. Constant terms e i in the equations 9 and 10are computed by executing the decision slices at I 0 .
Then the values of input I 0 and coefficient of equations recorded in Table 1 are put in the linear equations 9, 10 and equated with the corresponding values computed in Table 2.
Similarly value of e 2 is calculated and the values of a i , b i , c i and e i and corresponding functions 9 and 10 are recorded in the Table 3.

Computation of Decision Residuals
Decision slices corresponding each decision nodes on the activity path are executed with Decision residual at I 0 for decision nodes on Activity Path2 are recorded in Table 4: Table 4. Computation of decision residual I 0 Residual (100, 2, 220) R (DN 2 ,I 0 ,AP 2 )=20 (100, 2, 220) R (DN 3 ,I 0 ,AP 2 )=20 Construction of a system of linear constraints and to solve them to obtain increments for the current input: Linear arithmetic representation of decision nodes are converted into inequalities: Decision nodes corresponding decisional functions F 2 and F 3 which are given in Table 2 needs to be true for traversal of Activity path2 So we have taken the same relational operator as used in these decisional nodes and inequalities corresponding each nodes is written in equations 15, 16.
Then relaxation technique is applied to equations 15 and 16 and decision residual computed in Table 3. Set of constraints on increments of p, n and a are given in equations 17 and 18.

Converting the Inequalities into Equations
Inequalities are converted into equations by introducing the variable u: -2∆p-100∆n+∆a=-20 (20) Fig. 3. Screenshot of test data generated for test path2  Here computed new values lead to traversal of the desired activity path and computed new approximation of test inputs which traverse an activity diagram is obtained from previous approximation of the solution and it's residual. This technique will be used iteratively to obtain new input values until desired activity path is traversed.
Similarly test data for other test paths are calculated and recorded in Table 5.
Java programming language is used for implementation of the proposed approach. For the given problem there are two decision nodes 13 and 15 which take input values. Java program contains functions of the decision nodes 13and 15 of the programs. And Initial input is taken in the program as (p, n, a) = (100, 2, 220).
Then decision node symbol is provided based on the path traversal then our program generates test data corresponding that path. Fig. 3 shows the test data for test path 2.