Abstract: Correct functioning of object-oriented software UML models as a source of information in software testing
systems depends upon the successful interaction of objects and [1, 5, 6, 7, 9, 12, 15, 19, 21, 24, 27, 26, 28, 14]. Many UML
classes. While individual classes may function correctly, several design artifacts have been used in different ways to perform
new faults can arise when these classes are integrated together. different kinds of testing. For instance, UML statecharts
The interaction among classes has increased the difficulty of have been used to perform unit testing, and interaction
object-oriented testing dramatically. Currently traditional
diagrams (collaboration and sequence diagrams) have been
approaches generates testing paths from source code or UML1
diagram lacks of analysis and puts obstacles of automation of
used to test class interactions.
test case generation. In this paper, we present an integrated As the major benefit of object oriented programming,
approach to enhance testing of interactions among classes. The encapsulation aims at modularizing a group of related
approach combines UML2 sequence diagrams and statecharts functionalities in classes. However, a complete system-level
hierarchically and generate test paths based on message flow
functionality (use case) is usually implemented through the
graph. We have applied it to a case study to investigate its fault
detection capability. The results show that the proposed
interaction of objects. Typically, the complexity of an OO
approach effectively detects all the seeded faults. As a result, system lies in its object interactions, not within class
this work provides a solid foundation for further research on methods which tend to be small and simple. As a result,
automatic test case generation, coverage criteria analysis of complex behaviors are observed when related classes are
sequence diagram based object oriented testing. integrated and several kinds of faults can arise during
integration: interface faults, conflicting functions, and
Keywords: Software testing, UML model, sequence diagram,
missing functions [4]. Thus testing each class independently
statecharts diagram.
does not eliminate the need for integration testing. A large
number of possible interactions between collaborating
1. Introduction classes may need to be tested to ensure the correct
communication among classes and further functionality of
Nowadays, object-oriented paradigm has become a popular the system.
technology in modern software industry due to several
distinguish features, such as encapsulation, abstraction, and More and more software developers use UML and associated
reusability to improve the quality of software. However, visual modeling tools as a basis to design and implement
along with the development of object-oriented software, their applications. In addition, UML sequence diagram is
compared to testing of procedural software [10, 4], OO widely used for specifying the dynamic behaviors of classes
features also introduce new challenges for testers: and contains necessary information about object
communications and interactions between objects may give communications in terms of object life lines that is more
rise to subtle errors that could be hard to detect. Although, propitious to object-oriented software testing. Therefore, in
most traditional unit testing and system testing techniques the research reported in this paper, UML sequence diagram
may also be applicable to object-oriented testing, it still are used as a basis to generate message flow graph (MFG)
makes a great difference for testing of procedural software hierarchically. Firstly, we discuss an approach to generated
and object-oriented software since object communication hierarchical MFG based on sequence and state chart
and interaction may introduce more complicated and diagram of corresponding objects. After that, a verification
unforeseen situations. Therefore, it is necessary to explore method is provided for the coverage criteria.
new and effective object-oriented testing technique in theory The remainder of the paper is organized as follows. Section
and practice. 3 presents a brief survey of the related works in the areas of
The Unified Modeling Language (UML) has emerged as the state-based testing and UML-based test path generation. A
de facto standard for analysis and design of OO systems. description of classification with respect to UML2 diagrams
UML provides a variety of diagramming notations for is given in Section 2. Section 4 presents an approach to
capturing design information from different perspectives. generate a hierarchical message flow graph based test cases.
This approach can also derive independent testing path. A
In recent years, researchers have realized the potential of case study of a web-based information system is illustrated
74 (IJCNS) International Journal of Computer and Network Security,
Vol. 2, No. 9, September 2010
in Section 5. Conclusive remarks and future work are, transition system. The formalization of model based testing
finally, indicated in Section 6. represents a new trend of state based testing.
Although many works had been done on the OO testing of
2. Related Works sequence diagram and statecharts diagram, this work is
different from the above unit level testing in two aspects.
Traditional testing strategies for procedural programs, such First, this work presents a hierarchical synthesized approach
as data flow analysis and control flow analysis cannot be to sequence diagram testing using a message flow graph
directly applied to OO programs [22]. Extensions of these (MFG). The proposed MFG is generated from the statechart
techniques for OO programs have been proposed by Buy et that supports message generation in the sequence diagram.
al. [9] and Martena et al. [25]. A structural test case Secondly, the hierarchical structure provides a novel graphic
generation strategy by Buy et al. [8] generates test cases based testing technique for OO program validation.
through symbolic execution and automates deduction for the
data flow analysis of a class. Kung et al. [20] proposed an
idea to extract state models from the source code, whereas 3. Graph based Testing Approach
others suggest test generations from pre-existing state-
The run-time behavior of an object-oriented system is
models [12, 13, 29]. In the sections below, we will discuss
modeled by well-defined sequences of messages passed
more specific UML-based testing techniques.
among collaborating objects. In the context of UML, this is
Tse and Xu [30] have proposed an approach to derive test usually modeled as interaction diagrams (sequence and/or
cases from Object Test Models (OTM). State space collaboration diagrams). In many cases, the states of the
partitions of the attributes of a class are used with the OTM objects sending and receiving a message at the time of
to generate a test tree. The actual test cases are derived from message passing strongly influence their behavior in
the test tree. Nori and Sreenivas [26] have proposed a following aspects:
specification-based testing technique that splits the
• An object receiving a message can provide different
specifications of a class into structural and behavioral
functionalities in different states.
components. Structural aspects define the attributes and
method specifications of a class, whereas state machine is • Certain functionalities may even be variable or
used to defined the behavioral component that describes the unavailable if the receiving object is not in the
sequence of method invocation. In the work of [12, 28], an correct state.
idea of converting test generation into an AI planning
problem was proposed. UML statecharts are processed by • The functionality of providing object may also
planning tools and used to produce AI planning depend on the states of other objects including the
specifications. The test cases are generated based on the sending object of a message.
processed statecharts. Another example of statecharts based In this work, a graph based testing technique is proposed,
test case generation technique was proposed by Kim et al. which is on the idea that the communication between objects
[18]. These statecharts are transformed to Extended Finite should ideally be exercised (represented by sequence
State Machines (EFSMs) to generate test cases and then use diagram) for all possible states of the objects involved
traditional control and data flow analysis on the generated (statecharts diagram). This is of particular importance in the
test cases. context of OO software as many classes exhibit an
Several state-based approaches were proposed based on interaction state-dependent behavior. Such testing objective
state-chart or finite state machine. In the work of [23], Li et is implemented by generating a graph-based testing
al. presented an approach to testing specific properties of approach and testing path on message flow graph (MFG) on
reactive systems. Kim et al. [17] used statecharts to generate the defined criteria. The proposed technique can be applied
test sequences for Java-based concurrent systems. during the integration test phase, right after the completion
Kansomkeat and Rivepiboon [16] have converted UML of class testing. It consists of the following three steps:
statecharts into an intermediate model known as Testing 1. Message Flow Graph (MFG) Generation: We
Flow Graph (TFG). This graph reduces complexities of investigate the sequence diagram of the (sub)system,
statecharts and produces a simple flow graph. Test cases are and generate corresponding MFG following the MFG
finally generated by traversing the TFG using state and generation algorithm (will be discussed in the
transition coverage criteria. The proposed methodology was following section).
evaluated using mutation testing. Results of an experiment
carried out to validate the application of Round Trip Test 2. Hierarchical Testing Path Generation: Based on the
Strategy [4] on UML statecharts are presented in Briand et MFG of sequence diagram, for each object that we
al. [6]. Authors also propose improvements on the strategy concern, we refer the state-chart diagram and
based on the analysis of these results. Swain et al. has generate a MFG for some node of MFG.
proposed a method of statecharts and activity model based 3. Coverage Criteria: We test the sequence diagram
testing technique by constructing an intermediate model against the coverage criteria that we defined.
named state-activity diagram (SAD) [29]. Besides, some
recent work [11] was proposed using formalization on the In the following sub-sections, we describe the proposed
statechart diagram to perform model-based testing. In the testing technique in greater detail with the help of a simple
work of [3] a semantic model is proposed using the labeled example.
(IJCNS) International Journal of Computer and Network Security, 75
Vol. 2, No. 9, September 2010
We define dependency path as follows. For example, in Fig. 1, assume node N6 involve a series of
state transitions, then we can generate a subset of MFG GN6
Definition 2 (Dependency Path (DP)) Given a MFG G =< for it (Fig. 2).
N, E, L, I >, a dependency path (DP i) in G from node ni to
76 (IJCNS) International Journal of Computer and Network Security,
Vol. 2, No. 9, September 2010
analysis, pages 60–70, New York, NY, USA, 2000. International Workshop on Software Engineering
ACM. Tools and Techniques, 2001.
[16] S. Kansomkeat and W. Rivepiboon. Automated- [27] H. Reza, K. Ogaard, and A. Malge. A model based
generating test case using uml statechart diagrams. In testing technique to test web applications using
SAICSIT ’03: Proceedings of the 2003 annual statecharts. In ITNG’08: Proceedings of the Fifth
research conference of the South African institute of International Conference on Information Technology:
computer scientists and information technologists on New Generations, pages 183–188, Washington, DC,
Enablement through technology, pages 296–300, , USA, 2008. IEEE Computer Society.
Republic of South Africa, 2003. South African [28] M. Scheetz, A. v. Mayrhauser, R. France, E.
Institute for Computer Scientists and Information Dahlman, and A. E. Howe. Generating test cases
Technologists. from an oo model with an ai planning system. In
[17] S.-K. Kim, L.Wildman, and R. Duke. A uml ISSRE ’99: Proceedings of the 10th International
approach to the generation of test sequences for java- Symposium on Software Reliability Engineering,
based concurrent systems. In ASWEC ’05: page 250, Washington, DC, USA, 1999. IEEE
Proceedings of the 2005 Australian conference on Computer Society.
Software Engineering, pages 100–109,Washington, [29] S. K. Swain, D. P. Mohapatra, and R. Mall. Test case
DC, USA, 2005. IEEE Computer Society. generation based on state and activity models. Journal
[18] Y. Kim, H. Hong, D. Bae, and S. Cha. Test cases of Object and Technology, 9(5):1–27, 2010.
generation from uml state diagrams. Software, IEE [30] T. Tse and Z. Xu. Class-level object-oriented state
Proceedings, 146(4):187–192, 1999. testing: A formal approach. Technical Report HKU
[19] Y. Kim, H. S. Hong, S. Cho, D. H. Bae, and S. D. CSIS Technical Report TR-95-05, Department of
Cha. Test cases generation from uml state diagrams. Computer Science, The University of Hong Kong,
In In IEEE Proceedings: Software, pages 187–192, 1995.
1999. [31] Q. ul-ann Farooq, M. Z. Z. Iqbal, Z. I. Malik, and M.
[20] D. C. Kung, P. Hsia, Y. Toyoshima, C. Chen, and J. Riebisch. A model-based regression testing approach
Gao. Object-oriented software testing: Some research for evolving software systems with flexible tool
and development. In HASE ’98: The 3rd IEEE support. Engineering of Computer-Based Systems,
International Symposium on High-Assurance Systems IEEE International Conference on the, 0:41–49,
Engineering, pages 158–165, Washington, DC, USA, 2010.
1998. IEEE Computer Society.
[21] D. C. Kung, N. Suchak, J. Gao, P. Hsia, Y. Authors Profile
Toyoshima, and C. Chen. On object state testing. In
in Proceedings of Computer Software and Yujian Fu is an assistant professor at department of computer
Applications Conference, pages 222–227. IEEE science. Dr. Fu received the B.S. and M.S. degrees in Electrical
Computer Society Press, 1994. Engineering from Tianjin Normal University and Nankai
[22] D. C. Kung, N. Suchak, J. Gao, P. Hsia, Y. University in 1992 and 1997, respectively. In 2007, she received
Toyoshima, and C. Chen. On object state testing. In her Ph.D. degree in computer science from Florida International
in Proceedings of Computer Software and University. Dr. Yujian Fu conducts research in the software
verification, software quality assurance, runtime verification, and
Applications Conference, pages 222–227. IEEE
formal methods. Dr. Yujian Fu continuously committed as a
Computer Society Press, 1994. member of IEEE, ACM and ASEE.
[23] S. Li, J. Wang, and Z.-C. Qi. Property-oriented test
generation from uml statecharts. In ASE ’04: Sha Li is an associate professor at department of curriculum,
Proceedings of the 19th IEEE international teaching and educational leadership, school of education of
Alabama A&M University. Dr. Sha Li received his doctorial
conference on Automated software engineering,
degree of educational technology from Oklahoma State University,
pages 122–131, Washington, DC, USA, 2004. IEEE 2001. Sha Li’ research interests include distance education,
Computer Society. instructional technology, instructional design and multimedia for
[24] W. Linzhang, Y. Jiesong, Y. Xiaofeng, H. Jun, L. learning.
Xuandong, and Z. Guoliang. Generating test cases
from uml activity diagram based on gray-box method.
In APSEC ’04: Proceedings of the 11th Asia-Pacific
Software Engineering Conference, pages 284–291,
Washington, DC, USA, 2004. IEEE Computer
Society.
[25] V. Martena, A. Orso, and M. Pezz´e. Interclass
testing of object oriented software. In ICECCS ’02:
Proceedings of the Eighth International Conference
on Engineering of Complex Computer Systems, page
135, Washington, DC, USA, 2002. IEEE Computer
Society.
[26] A. V. Nori and A. Sreenivas. A technique for model-
based testing of classes. In Proceedings of the Second