KCC2013

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/255173345

A testing approach based on object interaction pattern in object oriented


system

Data · April 2013

CITATIONS READS

0 4,271

4 authors, including:

Muhammad Iqbal Hossain


BRAC University
35 PUBLICATIONS   44 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Malware Prediction Using Machine Learning View project

Indirect interaction testing for embedded system View project

All content following this page was uploaded by Muhammad Iqbal Hossain on 06 June 2014.

The user has requested enhancement of the downloaded file.


2013년 한국컴퓨터종합학술대회 논문집

객체지향 시스템의 객체 상호작용 패턴에 따른 시험 방법


O * * *
후세인무하메드입팔 정수용 이성희 이우진
경북대학교 IT대학 컴퓨터학부
milon_mi7@yahoo.com, kyo1363@naver.com, lee3229910@gmail.com, woojin@knu.ac.kr

A testing approach based on object interaction pattern in


object oriented system
O * * *
Muhammad Iqbal Hossain Souyong Jeong Lee Sung Hee Woo Jin Lee
School of CSE, Kyungpook National University
Daegu, South Korea

Abstract
Object-oriented paradigm has rapidly become the preferred model for system design by its
structuring mechanism. But Object oriented program causes dependency among the classes which
makes the testing procedure difficult. Although traditional testing techniques, based on UML diagram,
are used widely to test Object oriented program in isolation but the interaction between instances of
different classes has more importance. In this paper we propose different object interaction pattern
and generate test cases for each of the pattern using data flow among classes.

1. Introduction as branch coverage and path coverage, and are


defined in terms of the sequences of messages
Object-oriented paradigm has rapidly become the exchanged among a set of collaborating objects. A
preferred model for system design. When modeling systematic approach is proposed to test object-
something cohesive with state and associated actions oriented program at integration level[2]. In this
on those states, object oriented program have been approach test cases are generated from UML
used to encapsulate and abstract data and information sequence diagram and class diagram and implement
away. An object oriented program contains complex the test cases using the concept of coordination
interaction among sets of collaborating objects from contracts. Coordination contract is a connection that
different class. Testing the interaction between is established between groups of objects and used to
instances of different classes has more importance implement the test cases. It is very difficult to
than testing a class in isolation. Several testing implement coordination contract and special tools are
approaches are based on flow graph analysis or UML needed to implement coordinate contract concept.
interaction diagram like sequence diagram or
3. Object Interaction patterns
collaboration diagram. These techniques are based on
condition or branch coverage criterion and excessive In this section we present different object interaction
number of test paths are generated to cover those patterns according to data flow information[3].
criteria. In this paper, we categories different Usually object is instances of class, which is used to
interaction pattern between the objects on basis of interact with one another to design applications. A
data flow and propose test technique to test each of class contains a set of variables and operations. The
the patterns. interaction between objects depends how the member
variables and functions are used and updated among
2. Related work
classes.
Several testing approaches are based on interaction
3.1 Object reference sharing
diagrams that are constructed during analysis or
design. A reversed engineered sequence diagram In this pattern, one object’s reference is shared
approach is introduced to define a family of coverage among multiple objects. Basically in synchronizing
criteria object interaction[1]. The criteria are problem when an object is shared by multiple objects
generalizations of traditional control flow criteria such and always require current object state, one object’s
2013년 한국컴퓨터종합학술대회 논문집

reference is created and shared among other objects. member function of Utility class. To sort the student,
Let’s consider the producer/consumer problem reference of Student class object passed to Utility
represented in Figure 1. class. After sorting Utility class return sorted Student
object to Lecture class. Through this interaction the
Class Producer Class Buffer data of Student class is also sorted.
Class Consumer
- buffer: Buffer - buf: LinkList
- semaphore - items, size + ID
- mutex - bufferSize - buffer: Buffer Student LectureClass Utility
- full, empty
+ Buffer() - Consumer()
+ regNo + title
- Producer() + remove() + run()
+ name + credit
+ run() + add() - sort(student)
- modify() - grading() - calc()
Figure 1. Object reference sharing
Figure 3. Object passing by parameter or return type
In this example, producer and consumer class share
a fixed-size Buffer class. One object produces item 4. Data flow Driven Test Strategy
and puts it in the buffer, while the other object
consumes item from the buffer. These objects do not In this section we present the test strategy for each
take turns accessing the buffer, they both work of the pattern described in section 3. Our main focus
concurrently. To interact with same Buffer object by is on the data flow information between the classes.
producer and consumer class, the reference of Buffer Usually Dataflow testing is based on definition-use of
object is used. object variables[4]. Therefore data flow testing can be
3.2 Object reference exchange used to find object behavior fault.
In dataflow testing an assignment to a variable of a
The reference of object can be exchanged between class is tested by executing sub paths from the
two classes. The references of objects are sending as definition to points where the variable is used[5]. But
a parameter between themselves. The object states for the interaction between classes, variables can be
are always updated and exchange current state of used or defined in public method of another class. So
data. Here the data flow between the classes is the data flow path should contain a inter class data
bidirectional. flow information. Usually class call graph, class
Class Hand
interaction diagram are generated to find the
Class Table sequence. We illustrate object interaction sequence
+ m_card: double
+ m_hands: list<hand>
- Hand(Table &t) for each of the pattern in Table 1.
- getCard() - addHand(Hand &h)
- setCard() - showHands() Table 1. Data flow and interaction sequence of object
- show()

Pattern Object interaction sequence Propagated Variable


Figure 2. Object reference exchange
In Figure 2, a blackjack card table class represents a
table at which players might play and a Hand class
represents the various hands being played at the table.
Thus Table has a member which is a list of Hand
Also the variables are shown which are propagated
objects. Sometime a hand might need to split itself,
for each sequence that will be used to generate test
which would involve adding a new Hand to the Table's
cases for every sequence for each pattern.
list of hands. So the references of Table and Hand are
exchanged between each other.
5. Case study
3.3 Object Passing by Parameter or return type
Let’s consider the following class diagram which
Object can be created and passed as a parameter
shows some domain model for customer order in
to another class. In this case object reference is
Figure 4. The central class is the Order which is
passed in the interaction so any change to the object associated with the Customer making the purchase
will be reflected in the original object. In Figure 3,
and the Payment. A Payment is one of three kinds:
student grading system is illustrated. LectureClass
Cash, Check, or Credit. The order contains
needs to sort the student list. But sorting function is a OrderDetails each with its associated Item. Order has
2013년 한국컴퓨터종합학술대회 논문집

a collection of OrderDetails. When total amount or Acknowledgement


total weight is calculated in Order class, OrderDetails
This research was supported by the MSIP(Ministry of
must send the most recent updated value. On the
Science, ICT & Future Planning), Korea, under the
other hand, OrderDetails has an Item. Whenever a new
CITRC(Convergence Information Technology Research
is included the sub total and weight is calculate in
Center) support program (NIPA-2013-H0401-13-
OrderDetails. So in this case also the OrderDetails
1005) supervised by the NIPA(National IT Industry
reference is used. In this case reference of
Promotion Agency.)
OrderDetails object is used in Order and Item class
which is showed in bold line in the figure. References

[1] Rountev, S. Kagan and J. Sawin, “Coverage


Customer Order
+ name
1 0…*
+ date
criteria for testing of object interactions in
+ address + status sequence diagrams,” Conference on Fundamental
+ Customer()
1..* 1
+ clacTax() Approaches to Software Engineering 2005.
+ editInfo() Payment + calcTotal()
+ calcTotalWeight() [2] Zhe(Jessie) Li and T. Maibaum, “An Approach to
+ amount
1 Integration Testing of Object-Oriented Programs,”
1..*
Seventh International Conference on Quality
OrderDetail
+ quality
Software, 2007.
+ taxStatus [3] Y. Tsai, S. Stobart and N. Parrington “Employing
+ calcSubTotal() data flow testing on object oriented classes,” IEEE
+ calcWeight()
0..*
Proceeding-Software, 2001.
Credit Cash Check 1 [4] Tsai, S. Stobart and G. Tang, “Performing Data
+ number + cashTend + name Item
+ type + bankID
Flow Testing on Object-Oriented Classes.”
+ expDate + shipWight
+authorized() + description International Conference on Advanced Science
+authorized()
+ getPricel() and Technology, 2000.
+ getWeight()
[5] M. Harold and G. Rothermel, “Performing Data
Flow Testing on Classes,” ACM SIGSOFT
Figure 4. Class diagram of customer order domain symposium on Foundations of software
engineering, 1994.
Other object interaction patterns can be found in
some real life example like: ATM machine, Online
bookstore, Hospital management system etc.

6. Conclusion
In this paper, we have presented different object
interaction patterns and test strategies for the patterns.
We have shown three kinds of interaction pattern
between classes and generate data flow interaction
between classes according to the interaction pattern.
Finally data flow testing technique is used to generate
test cases. Interaction between classes is an important
issue while adding some new class in our system. By
acquiring the interaction pattern with other classes, it
is easily perform regression testing of the system. We
are investigating other object interaction patterns
between classes and reorganizing data flow testing
technique.

View publication stats

You might also like