Issues in OO Testing1
Issues in OO Testing1
|
?
|
¦
?
Implications of inheritance
± New context of usage
± Multiple Inheritance
± True specialization -- reuse of test cases
± Programming convenience -- must test subclasses and
superclasses
|
¦
?
Implications of encapsulation
± Makes reporting on state difficult
± Correctness proof may help but difficult
Implications of Polymorphism
± Each possible binding requires separate test
± Makes integration more difficult
|
¦
?
White-box testing
± Appropriate only for methods not for classes
± Control graph testing is not applicable to methods
Black-box testing
± Applicable to classes
± The distance between OO specification and
implementation is small compared to conventional
systems.
|
¦
?
Integration strategy
± Thread-based: All classes needed to respond to certain
external input
± Uses-based: Starts with classes that do not use other
classes; then continue with classes that use the first
group and so on.
Test process strategy
± Design a little, code a little, and test a little cycle
|
?
?
?
|
!?
What is a unit?
± A single, cohesive function?
± A function whose code fits on one page?
± The amount of code that can be written in 4 to 40
hours?
± Code that is assigned to one person?
In object-oriented programs, a unit is a method
within a class.
|
" ?
#!?
Statement coverage
Graph based
± Branch coverage
± Condition coverage
± Path coverage
All unit testing methods are also applicable to
testing methods within a class.
|
¦ ?
Strategies:
± Bottom-up guided by functional decomposition tree
± Top-down guided by functional decomposition tree
± Big bang
± Pairwise
All focus on structure and interface
|
?
Performed exclusively in terms of inputs and
outputs of the system
Performed mostly on the target platform
Thread-based:
± The behavior that results from a system level input
± An interleaved sequence of system inputs (stimuli) and
outputs (responses)
± A sequence of transitions in a state machine model of
the system
|
? ?
! ! ?
?
|
?
|
?
|
?
'
(((())
(((()
*
(((())
(((()
+
(((())
(((()
|
,
|
--
|
?
New methods: defined in the class under test and
not inherited or overloaded by methods in a
superclass: Complete testing
Inherited methods: defined in a superclass of the
class under test: Retest only if the methods
interacts with new or redefined method.
Redefined methods: defined in a superclass of but
redefined in the class under test : complete
Retest reusing tests from the superclass.
|
? ?
|
??
A state-transition model describes the different
states and transitions of a class in the context of its
position in the inheritance hierarchy.
r
The of an object is the combination of all the
attribute values and objects that the object
contains.
An object may from a state to state as a
result of an , which may yield an
|
/
0 /
/
.
/
|
??
|
%¦ &?
A cluster is a collection of classes (possibly from
different systems) cooperating with each other via
messaging.
A cluster specification should include methods from
each class that will be accessed
Cluster testing focuses on the interaction among the
instances of the classes in the cluster
It assumes that each class has been tested individually
Cluster testing is considered a second level of
integration testing
|
%¦ &?
Event-Driven execution
No functional decomposition
The sequence of execution is not known
Integration testing must be driven by how object
will behave dynamically
Object composition introduces a new dimension of
integration testing
|
? #
¦ ?
Messaging errors:
± Failure to meet a requirement, i.e., no method to send
or receive a message
± Incompatible method and message in sender and
receiver
± Incorrect event timing between object actions
± Incorrect instantiation or destruction of objects
|
? #
¦ ? %
)&
User interface errors:
± A given sequence of user actions does not have the
expected effect on the component.
± The timing of events received from the user results in
incorrect functioning of the component
|
#
Function-based clustering
± Based on requirements and use cases
± Difficult to perform if requirements were not available
during the design phase
Subject-based clustering
± Based on subject areas that need to test separately
Project Schedule-based clustering
Contract-based clustering
|
?
¦ ?
Message Quiescence
Event Quiescence
|
1
|
2 34
+
'
*
'
'
*
+
*
'
+
*
|
+
'
*
'
'
*
+
*
'
+
*
|
/ 1
*
'
'
'
*
+
*
*
|
?
User dials the number System plays greeting and ask for account number
User enters invalid account number System informs user and ask for account number
again
|
?
|
?
CRC cards
± English text descriptions of a single class, its
responsibilities, and it collaborators with other classes
Class specifications
± Complete specification of a class including its data
structure, method names, number and type of
parameters, return values, pre- and post-conditions.
Use cases
± A representation of the systems usage
|
?
% )&
State-Transition Models
± State transition diagrams for classes, clusters, and
subsystems
Object network
± Message sequence between methods in classes
Transaction-Flow Models
|
?
Criteria
± Correctness
± Completeness
± Consistency
Early informal models are tested informally
The criteria should be interpretive in the context of
iterative incremental approach
|
?
Testing by comparison
± compares each model to its predecessor or to previous
forms of the model
Testing by inspection
± uses checklists to make sure that the model meets
certain criteria
Testing by verification
± follows certain steps to assure completeness and
consistency of one part of the model with another
|
The OO is not always the best approach to system
development.
Claimed benefits of the OO approach can only be
obtained through:
± Robust development process
± Good development practices by individuals
± Automated tools
The OO approach introduces substantial
difficulties to the testing process.
|