You are on page 1of 5

2014 International Conference on Intelligent Computing Applications

An Approach to Generate Test Cases from


Sequence Diagram

M.Dhineshkumar, PG Scholar,Professor.Mr.Galeebathullah

Department of Computer Science and Engineering

Sona College of Technology, Salem-636005

dhineshmsc2011@gmail.com, kalifathullah@gmail.com

Abstract
Testing is an important area of software engineering. There are II.RELATED WORK
various types of testing methodologies followed in various stages of There are many of researchers proposed many
Software Development Life Cycle (SDLC). We are proposed a novel methodologies for scenario level test case generation. Most
approach for generating test cases from UML sequence diagram. Our probably they used black box approaches and they do not
approach consists of transforming sequence diagram in to sequence
diagram graph and generating test cases from SDG. The sequence
considered architectural behavioural designs. In the software
diagram is prepared based on the Use Case diagram in which development life cycle from requirement specification to
describes the overall view of the system. The traceability between the actual product, the verification and validation takes place.
models is provided by using Relational Definition Language. Probably the products were verified and validated based upon
Keywords: Model Based Testing, Sequence diagram, SDG, test case their requirement specifications. More recently model based
Generation,OCL. testing become as popular. Marketing proposes various
methodologies in model based testing. Model paradigm
I. INTRODUCTION contains state based notations, transition based notations,
Testing performs an important role in software history based notations, functional notations, operational
engineering, which only ensures the quality of software being notations and criteria for test selection, in which includes data
produced. Most of the testing methodologies involves in the coverage, requirement based coverage, fault based criteria and
Black box approach, while compared to design level testing. about the different types of tools used in model based
Before testing, the development life cycle reduces the testing[1].
difficulties on implementation level. Combination of State machine diagrams and Class diagrams
In model based testing, the test cases are generated [2] used to generate automatic test cases using OCL
from the abstract representation of the model. The Abstract expressions. This algorithm is used with ParTeG. Static
test suites are not executed against system under test because analysis tools such as OCLE [Chiorean] and USE [Richter’s]
it is needed to be described from the corresponding abstract [3] can be used to analyze structural properties of Class
test suite. The effect of model based testing is it offers Models. This approach removes manually simulating the
automation of testing. If a model is readable one then it should behaviour of Class Models. Instead of that it provides a light
have a well defined behavioural interpretation. During testing weight approach to check scenarios.
the model and its behavioural specification is given to model AGEDIS [4] includes an integrated environment for
checker. After the verification the paths were used for modelling test generation, test execution and other related
generating test cases. Here a little knowledge of the coding is activities for industries. This is widely accepted tool by
needed for the tester instead of brief knowledge about coding industries, but it has some drawbacks. Briand and Labiche [5]
in testing. They must to understand the UML models which is describe the TOTEM (Testing Object Oriented Systems with
used for System under Test. the Unified Modelling language) system testing methodology.
Model based testing provides the conformance with System test requirements are derived from early UML
the UML diagrams. In the case of design level there are analysis artefacts such as, use case diagrams and sequence
various diagrammatic representations used to represent the diagrams associated with each use case and class diagram.
operations with operational requirements. Here we are using For testing different aspects of object interaction,
the Use case diagrams to get the requirements involved in the several researchers have proposed different technique based
system and tracing the important scenarios to sequence on UML interaction diagrams [6,7,8,9,10] , Bertolino and
diagram and converting in to sequence diagram graph. By Basanieri proposed a method to generate test faces using the
using the sequence diagram graph test cases are generated. UML use case and Interaction diagrams(specifically, the

978-1-4799-3966-4/14 $31.00 © 2014 IEEE 345


DOI 10.1109/ICICA.2014.77
Message Sequence diagram). It basically aims at integration A. SYSTEM ARCHITECTURE
testing to verify that the pre-tested system components interact
correctly. They use category partition method and generate
test cases manually following the sequences of messages
between components over the Sequence Diagram.
From the use case diagram, the Use Case
Dependency Graph (UDG) and Concurrent Control Flow
Graph (CCFG) from corresponding sequence diagrams for test
sequence generation [11]. UML state charts provide a solid
basis for test generation in a form that can be easily
manipulated [12]. The traceability between UML Models
provides reengineering [13] it increases the test case coverage
in test case generation. Bertolino and Maechetti[14] proposed
and approach to generate test cases even the software’s are
partially model. The OCL [15] is a Generalized Model free
Language and it is possible to combine programming
languages and OCL in UML model processing. It is model
language primarily meant for expressing constraints in model.
VikasPanthi and Durga Prasad Mohapatra [16]propose an
approach to generate test cases from sequence diagram by
generating extended finite State Machine for the diagram.
They proposed an algorithm named as ATGSD algorithm,
which focuses on the object coverage Message sequence Path
Criterion, Full Predicate Coverage and Boundary testing Fig.1 System Architecture
criteria.Traceability [17] between the models, which ever
constructing from the UML can be done easily.

III. PROPOSED APPROACH

The proposed approach describes the following steps to


generate test cases from the sequence diagram. Given a
sequence diagram (SD), in which describes the detailed
interaction of use cases and the actors involved in the system.
We transform it in to sequence diagram graph (SDG), the
sequences are traced from the use case diagram. The sequence
diagram is built with object constraint language(OCL), which
is a generalized language proposed for UML Models by object
management group.
The OCL gives the input condition and output condition
in the name of pre condition and post condition, which
represents before execution of the state and after execution of
the state of the behaviour involved in the sequence diagram. Fig 2. Sequence diagram for ATM Banking System
The sequence diagram is converted into XML format. The
XML file is converted into a Graphical notation called as tree
structure. The structure is named as sequence dependency
graph (SDG).
We then traverse the sequence diagram graph and
generate test cases based on path coverage, functional
coverage criteria. An algorithm is proposed for generating test
cases. The algorithm used for traversing the graph is described
in detail in the following section. The following architecture
such that Figure1 describes the schematic representation of
proposed approach.
Fig.3 Sequence Dependency Graph for thesequence diagram

346
TABLE I
TEST CASE GENERATION FROM SDG

Test case STARTIN DEPENDENT INPUT TO EXPECTED ACTUAL


ID G NODE NODE THE NODE RESULT RESULT

1 A B Switch on System loading System loading


2 B B Perform start up Performing system Performing System
start up Start up
3 B A Get initial cash Loading Cash Loading initial
cash
4 A B load initial cash Getting Cash Basic Balance
Loaded
5 B C Set basic cash Setting basic Balance
balance Loaded
6 B D Open System Loading Connection
Connection Launched

B. ARCHITECTURERAL DESCRIPTION C. AN EXAMPLE


We have taken the example of ATM Banking System
USE CASE DIAGRAM for generating test cases. The user before entering into the
The use case diagram describes the overall system, system, the cash dispenser will be loaded by the authorities of
which contains the actors and use cases in the system in a respective bank with the existing amount of dispenser.
sequence. The external persons or actors who will interact For that the how could be the test cases are generated
with each other through use cases. was shown here above in the test case table. Initially the
sequence diagram for the ATM Banking system will be drawn
SEQUENCE DIAGRAM in the Eclipse software development kit. The necessary UML
The sequence diagram describes the detailed plug-in were installed into the Eclipse before generating the
description and interaction with in the use case and actor. The diagram. The Eclipse supports the generation of UML
interactions are written in OCL (Object Constraint Language), diagrams and it also supports the OCL expressions. The
which is a generalized model free language. So this allows the complete scenario can be generated for ATM banking system
user easily to understand about the system interactions. The with the use of Eclipse .this diagram contains the sequence of
sequence diagram is shown in the figure 2 for ATM system. interactions between the operator panel, ATM machine, cash
dispenser and bank authorities.
TOOL CONVERSION The sequence of interactions shown in the ATM
The sequence diagram can be exported into an banking system sequence diagram can be converted into an
XML/XMI format using an XML parser. This file contains all XML format. The conversion of XML file can be done
the XML tags that describe the sequence diagram. The automatically by using the XML file conversion option
diagram parameters and its values defined in XML format. already available in the Eclipse. The XML file represents the
sequence of interactions with its functional notations. It
SEQUENCE DIAGRAM GRAPH bridges the gap between different of interactions among the
The sequence diagram graph defines the activities as sequences.
nodes and the interactions in the form of paths. The SDG will The XML file of sequence diagram will be converted
look as an acyclic graph notation. By using this SDG the test to sequence dependency graph as well as sequence diagram
cases are generated. The sequence diagram graph has the graph. The sequences of activities in the ATM sequence
graphical structure like Figure3. It shows the graphical diagram are represented as nodes and the interactions among
notation of the sequence diagram of ATM system. those nodes are represented as paths between the nodes. The
test cases are generated from the sequence dependency graph
TEST CASE GENERATION by visiting the nodes and paths.
The test case is generated by visiting the nodes and The final output of the system will be number of
edges in the SDG. We were proposed the algorithm called as nodes visited and paths visited by the given condition
Iterative Deepening Depth first search algorithm (DFS). Using satisfaction criteria. During visiting the nodes some of the
this algorithm the test cases are generated, which reduces the nodes and paths are repeated to satisfy the condition criterion.
time taken to visiting the interactions which takes long time. It The test case generation table (Table1) shown here is for
increases the path coverage criteria. The table.1 shows some understanding purpose. The output will not be look like as we
of the sample test cases generated from the SDG depending on shown in the table1. So that the condition looked on the path
the condition. during test case generation is shown in table.

347
1) ALGORITHM USED FOR TEST CASE GENERATION Where E- is the number of edges.
The order of visiting nodes without repetition is calculated as
1. Procedure idvisit (G, S, Goal) Where b- branching factor and d-depth.
2. Inputs o(| b d |)
3. G: Graph with nodes N and paths A Traversing the entire graph without repetition (visiting the
4. S: Set of start nodes longest length paths) calculated as
5. Goal:Boolean functions on states
6. Output o(| v |)
7. Paths from S to a node for which is true Where v-number of vertices
Test case condition This formula includes without eliminating the visiting of
8. Local duplicate nodes.
9. Natural failure Boolean
10. Bound: integer D. TEST CASE GENERATION FROM SDG
11. Procedure dbsearch (n0 ...nk, b) The sequence diagram depicts the behaviour of
12. Inputs various sequences of the System under Test (SUT). Among all
13. n0,.....,nk,..Paths: other UML diagrams the sequence diagram only depicts the
14. b: integer, b>=0 behaviour among the sequences in a timely manner. The
15. Output immediate request and responses of system are modelled by
16. Path to goal of length k+6 sequences for test case generation. From the sequence
17. if (b>0) then diagram graph when an object invokes another object the
18. For each path nk, n A do system predicts whether the right sequence of messaging is
19. dbsearch(n0,...,nk, n b-1) followed to accomplish an operation. The SDG eventually
20. elseif (goal(nk)) then covers all the paths from the starting node to final nodes well
21. return no,......nk as message sequence paths. We are going to use the iterative
22. else if (nk has any neighbours) deepening depth first search algorithm in the sequence
23. natural failureÅ false then diagram graph to generate test cases. The complete path
24. boundÅ 0 coverage, Branch coverage can be predicted through this
25. repeat algorithm. The interaction which takes long time between the
26. natural_failureÅ true paths is found by this algorithm.
27. dbsearch ({S:s S } bound)
28. boundÅbound +1 IV. CONCLUSION
29. until natural_ failure
30. return We are proposed a novel approach to generate test
cases from sequence diagram by generating sequence diagram
The test case generation is starts from the initial node s which graph. The input of pre-condition and post-condition retrieved
is a subset of S. the nodes in the graph are starts from n0 ends from Usecase diagram and OCL expressions. These things
with nk,which is called as last node. During visiting of paths were stored in SDG. The iterative deepening depth first search
the nodes has more paths to visit the bound is increased as algorithm can handle the sequence of interactions among the
boundÅbound+1. When the condition is not satisfied, then sequences, in which takes long time.
the node will be terminated from traversing. This algorithm is
called as iterative deepening depth first search algorithm, in REFERENCES
which combines the features of basic depth first search and [1] Mark Utting, Alexander Pretschner and Bruno Legeard,
breadth first search algorithms to make effective test case “Taxonomy of Model Based Testing Approaches”.Software
generation. This algorithm takes less time to visit the nodes Testing, Verification and Reliability, John Wiley&sons, Ltd.,
when compared to other algorithms. A largest tree comprised 2010.
[2] Stephan WeiBleder Bernd-HolgerSchlingloff, “Deriving Input
of several nodes and paths, it can be handled by iterative Partitions from UML Models for Automatic Test Generation”,
deepening depth first search algorithm effectively.The 2008.
existing basic depth first search algorithm requires medium [3] Lijun Yu, Robert B.france, Indrakshi Ray, “Scenario-based static
sized graphs to traverse. This algorithm will not handle large analysis of UML class models”, LNCS 5301, PP.234-248, 2008,
Springer-VerlagBerlin Heidelberg, 2008.
sized graphs and it takes more time to traverse on the space. [4] A.hartman and K.Nagin, “The AGEDIS Tools for Model Based
Testing”, IBM Haifa Research Laboratory, ISSTA’04, July 11-14,
2) CALCULATIONS IN GENERATING TEST CASE FROM ACM 1-58113-820-2/04/0007, 2004.
SEQUENCE DEPENDENCY GRAPH (SDG) [5] L.C Briand and Y.Labiche, “A UML – Based Approach to System
Testing”. In Proceeding of the 4th International Concepts, and
Tools, Springer-Verlag, London, pp 194-208, October 01-05,
After generating test cases from the SDG, the 2002.
traversing of nodes and paths calculated by the following [6] A.Abdurazik, and J.Offutt, “Using UML Collaboration diagrams
formulas. for static checking and test generation”, Proceedings of the Third
International Conferences on the UML, Lecture Notes in
The worst case performance for explicit graphs traversed Computer Science, Springer-Verlag GmbH, York, UK,
without repetition is calculated as vol.939,2008,pp.383-395.
o(| E |)

348
[7] M.LettrariM.andJ.Klose and A Ruder, “Scenario-Based Computer Science Volume 1723,Springer-Verlag Berlin
Monitoring and Testing of Real Time UML Models”, In the Heidelberg. 1999.
Proceedings of UML-2001, Springer-Verlag, pp.312-328. [14] A.Bertolino and E.marchetti, H.Muccini,” Introducing a
[8] F.Basanieri, A.Bertolino, and E.Marchetti, “The Cow Suite Reasonably Complete and Coherent Approach for model-based
approach to planning and deriving test suites in UML projects”, In Testing”, Electronic notes in Theoretical computer science,
Proceedings of the 5th international Conference on the UML, ELSEVIER, 2005.
LNCS,2460,2002,pp.383-397. [15] MiikaSikarla, JariPeltonen and Petri Selonen,”Combining OCL
[9] P.Tonella, and Potrich, “A Reverse Engineering of the Interaction and Programming Languages for Model Processing”, Electronic
Diagrams from C++ code”, In the Proceedings of IEEE Notes in Theoretical Computer Science 102 (2004)175-
International conference on Software Maintenance (2003) 159- 194.ELSEVIER.
168. [16] VikasPanthi , Durga Prasad Mohapatra ,”Automatic Test Case
[10] F.Fraikin, and T.Leonhardt, “SIDITEC-testing based on sequence Generation Using Sequence Diagram”, International Journal of
diagrams, in Proceedings 17th IEEE International conference on Applied Information Systems(IJAIS)-ISSN:2249-0868,Foundation
ASE”, 2002, pp.261-266. of Computer Science FCS,New York,USA,Volume2-
[11] Santhosh Kumar Swain, Durga Prasad Mohapatra and Rajib Mall, No.4,May2012.
“Test Case Generation Based on Use Case and Sequence [17] Mathew George, Klaus-Peter Fischer-Hellmann,
Diagram”, International journal of Software Engineering, IJSE, MartinKnahl,UdoBleimann and Shirely Atkinson ,” Traceability in
July2010. Model Based Testing”, Future Internet-2012,4,1026-
[12] Clementine Nebut, Franck Fleurey, Yves Le Traon, member IEEE 1036;doi:10.3390/fi4041026.
and Jean-marc Jezequel Member, IEEE, “Automatic Test
Generation: A use Case Driven Approach”, IEEE Transactions on
Software Engineering, Vol.32, 17th march 2006.
[13] Jeff Offutt and AynurAbdurazik, George Mason University, USA,
“Generating Tests from UML Specifications”, Lecturer Notes in

349

You might also like