Sei sulla pagina 1di 45

Object Oriented Testing- Testing of OOA &

OOD Models

9/18/16

Outline
1.Object oriented Concept.
2.Object oriented testing : Introduction.
3.Testing of OOA and OOD Models
(i) Correctness of OOA and OOD models.
(ii) Consistency of OOA and OOD models.
4. Object Oriented Testing Techniques
(i) Unit testing or class testing.
(ii) Integration Testing.
(iii) Validation Testing.
5.Object oriented Testing Methods.
(i) Testing methods at class level.
(ii) Testing methods at Inter Class level.
6.UML Model Based Testing for Object Oriented System.
7.Conclusion
8.References
9/18/16

1.Object Oriented Concepts

Object
Class
Encapsulation
Polymorphism
Inheritance

9/18/16

Object Oriented Concepts : Object


Object is an operational entity which is associated with
data member and methods.
Life cycle of an Object begins when it is created,
proceeds through a series of operations and ends when
the object is destroyed.
Testing issues related to object is to check the following :
- Whether the object behave according to its
specification.
- Whether it interacts appropriately with
collaborating objects in an executing program.
9/18/16

Object Oriented Concepts : Class


A Class is a set of Objects which share common
properties .
These common properties describe what object can
do and how each object carries out what it can do.

9/18/16

Object Oriented Concepts : Encapsulation

A wrapping up of data and functions into a single


unit is known as encapsulation. This restricts
visibility of object states and also restricts
observability of intermediate test results and keep
safe it from outside environment.

9/18/16

Object Oriented Concepts :

Polymorphism

Polymorphism is one of the crucial features of OOPS. It


simply means one name multiple forms. Because of
polymorphism, all possible bindings have to be tested. All
potential execution paths and potential errors have to be
tested.

9/18/16

Object Oriented Concepts : Inheritance


The mechanism of deriving a new class from an old
one is called inheritance. The old class is referred to
as the base class and the new one is called the derived
class or the subclass. Inheritance results in invisible
dependencies between super/sub-classes. Inheritance
results in reduced code redundancy, which results in
increased code dependencies.

9/18/16

Representation of Object and Class in UML

9/18/16

Inheritance Representation in UML

9/18/16

10

2.Object Oriented Testing : Introduction


The process of testing object-oriented systems begins with a
review of the object-oriented analysis and design models.
Once the code is written object-oriented testing (OOT) begins
by testing "in the small" with class testing (class operations
and collaborations). As classes are integrated to become
subsystems class collaboration problems are investigated.
Finally, use-cases from the OOA model are used to uncover
software validation error.
Object oriented testing activities include Review of OOA and
OOD Models, Class testing or Unit Testing, Integration
testing, System testing and Validation Testing.
9/18/16

11

3.Testing of OOA and OOD Models


OOA and OOD models are tested or reviewed for their Correctness
and consistency.
The review of OO analysis and design models is especially useful
because the same semantic constructs (e.g., classes, attributes,
operations, messages) appear at the analysis, design, and code
level.
Therefore, a problem in the definition of class attributes that is
uncovered during analysis will circumvent side affects that might
occur if the problem were not discovered until design or code (or
even the next iteration of analysis).
9/18/16

12

Correctness of OOA and OOD Models


Correctness of OOA and OOD Models include the Syntactic
and Semantic correctness.
Syntactic correctness is Judged by ensuring that proper
modeling conventions and symbolism have been used .
Semantic correctness is Based on the model's conformance to
the real world problem domain
To determine whether the models does, in fact, reflect real
world requirements, it should be presented to problem domain
experts who will examine the class definitions and hierarchy
for omissions and ambiguity.

9/18/16

13

Correctness of OOA and OOD Models


( Continue....)
If the model accurately reflect the real world (to a level of
detail that is appropriate to the stage of development at which
the model is reviewed) then it is semantically correct.
Class relationships (instance connections) are evaluated to
determine whether they accurately reflect real-world object
connections.

9/18/16

14

Consistency of OOA and OOD Models


Consistency of OOA and OOD models assess the classresponsibility-collaborator (CRC) model and object-relationship
diagram .
Review system design (examine the object-behavior model to check
mapping of system behavior to subsystems, review concurrency and
task allocation,
use -case scenarios to exercise user interface design)
Test object model against the object relationship network to ensure
that all design object contain necessary attributes and operations
needed to implement the collaborations defined for each CRC card .
Review detailed specifications of algorithms used to implement
operations using conventional inspection techniques
9/18/16

15

CRC Cards
To assess consistency, each class and its connections to
other classes should be examined. The class-responsibility
collaboration model and an object-relationship diagram can
be used to facilitate this activity.
The CRC model is composed on CRC index cards. Each CRC
card lists the class name, its responsibilities (operations),
and its collaborators (other classes to which it sends
messages and on which it depends for the accomplishment
of its responsibilities).
The collaborations imply a series of relationships (i.e.,
connections) between classes of the OO system. The objectrelationship model provides a graphic representation of the
connections between classes. All of this information can be
obtained from the OOA mode
9/18/16

16

Example for CRC card index

9/18/16

17

Example for CRC card

9/18/16

18

4. Object Oriented Testing Techniques: Unit


Testing
The smallest testable unit is the encapsulated class.
Each operation as part of a class hierarchy has to be
tested because its class hierarchy defines its context of
use, New methods, inherited methods and redefined
methods within the class have to be tested.
This testing is performed using the following
approaches:- Test each method (and constructor) within a class
-Test the state behaviour (attributes) of the class
between methods
9/18/16

19

Object Oriented Testing Techniques: Unit


Testing (Continue....)
Test cases should be designed so that they are explicitly
associated with the class and/or method to be tested. The purpose
of the test should be clearly stated. Each test case should contain:
- A list of messages and operations that will be exercised as
a consequence of the test .
- A list of exceptions that may occur as the object is tested .
- A list of external conditions for setup (i.e., changes in the
environment external to the software that must exist in order to
properly conduct the test) .
- Supplementary information that will aid in understanding or
implementing the test .
9/18/16

20

Object Oriented Testing Techniques: Integration


Testing
Integration testing in Object oriented system focuses on
groups of classes that collaborate or communicate in some
manner.
Following approaches are used I for integration testing :
- Thread-based testing, which integrates classes required
to respond to one input or event.
-Use-based testing, which integrates classes required by
one use case.
- Cluster testing, which integrates classes required to
demonstrate one collaboration.
9/18/16

21

Object Oriented Testing Techniques: Validation


Testing
Validation testing in object oriented system focuses
on visible user actions and user recognizable outputs
from the system .
validation tests are based on the use-case scenarios,
the object-behavior model, and the event flow
diagram created in the OOA model
conventional black-box testing methods can be used
to drive the validation tests

9/18/16

22

5. Object oriented Testing Methods : At the


Class Level
Random testing - requires large numbers data permutations and
combinations, and can be inefficient .
- Identify operations applicable to a class.
-Define constraints on their use.
-Identify a minimum test sequence
- Generate a variety of random test sequences.
Partition testing - reduces the number of test cases required to
test a class
state-based partitioning - tests designed in way so that
operations that cause state changes are tested separately from
those that do not.
9/18/16

23

Object oriented Testing Methods : At the Class


Level ( Continue...)
Attribute-based partitioning - for each class attribute,
operations are classified according to those that use the
attribute, those that modify the attribute, and those that do
not use or modify the attribute .
Category-based partitioning - operations are categorized
according to the function they perform: initialization,
computation, query, termination.

9/18/16

24

Testing Methods at Interclass Level


Cluster Testing - Concerned with integrating and testing
clusters of cooperating objects. Identify clusters using
knowledge of the operation of objects and the system features
that are implemented by these clusters
Approaches to cluster testing
Use-case or scenario testing - Testing is based on a user
interactions with the system. Aadvantage is that it tests
systems features as experienced by users
Thread testing tests the systems response to events as
processing threads through the system
Object interaction testing test sequences of object
interactions that stop when an object operation does not
call on services from another object
9/18/16

25

Testing Methods Applicable at Interclass Level


Use Case/Scenario-based Testing
Based on
Use cases
Corresponding sequence diagrams
Identify scenarios from use-case and supplement these with
interaction diagrams that show the objects involved in the
scenario
Concentrates on functional requirements
Every use case
Every fully expanded (<<extend>>) combination
Every fully expanded (<<uses>>) combination
Tests normal as well as exceptional behavior
9/18/16

26

6.UML models based testing : Use Case


Diagram

A collection of use cases defines:


- Complete functionality of the system.
- Use cases roughly capture system level requirements.
Several general kinds of tests can be derived from use cases(a) Tests for basic courses-- the expected flow of events mainline
sequence.
(b) Tests of other courses-- all other flows of events alternate sequences.
(c) Tests of features described in user documentation traceable to each use
case.
Generic test requirements include:
At least one test case should exercise:
Every Use Case when actor communicates with Use Case.
Every extension combination such as Use Case 1 extends Use Case 2.
Every uses combination such as Use Case 1 uses Use Case 2.

9/18/16

27

Example for Use case Diagram

9/18/16

28

UML models based testing : Class Diagram


Documents the structure of a system:
Represents the entities and their inter-relationships.
Test cases should exercise:
Each association.
Independent creation and destruction of the container and
the components in an aggregation relation.
Each inherited method should be retested.

9/18/16

29

Example for Class diagram

9/18/16

30

UML models based testing : Sequence Diagram


A sequence diagram documents message exchanges
in time dimension.
Generic tests include:
Message coverage: At least one test case should
exercise each message.
Message path coverage: All end-to-end paths
should be identified and exercised.

9/18/16

31

Example for sequence diagram

9/18/16

32

UML models based testing : Activity Diagram


Activity diagrams are based on:
Flow charts, state transition diagrams, flow graphs;
Can be considered to be an extension of flow chart:
Can represent two or more threads of concurrent
execution.
Supports all features of a basic flow graph:
Can be used to develop test models for control flow
based techniques.
9/18/16

33

Example for activity diagram

9/18/16

34

UML models based testing : Statechart Diagram


Can be used to represents state-based behaviour of a
class, subsystem, or system.
Statechart model provides most of the information
necessary for class-level state-based testing

9/18/16

35

Example for statechart diagram

9/18/16

36

UML models based testing: Collaboration


Diagram
Represents interactions among objects.
A collaboration diagram specifies the implementation of a use
case.
May also depict the participants in design patterns.
Each collaboration diagram represents only one slice of the
IUT.
A composite collaboration diagram would be necessary to
develop a complete test suite for an implementation
9/18/16

37

Example for collaboration diagram

9/18/16

38

UML models based testing : Component


Diagram
Shows the dependency relationships among
components, physical containment of components,
Interfaces and calling components.
The basic testing practice with respect to component
diagrams include all call paths should be identified
and exercised.

9/18/16

39

Example for component diagram

9/18/16

40

UML models based testing : Deployment


Diagram

Represents hardware, software, and network


architecture. which is useful in integration planning.

When a component runs on a node, Test cases should


exercise whether a component can be loaded and run
on each designated host node.

When a node communicates with another node, Test


cases should exercise open, transmit, and close
communication for each remote component.

9/18/16

41

Example for deployment diagram

9/18/16

42

7.CONCLUSION
In Object Oriented environment the main
troublemakers that cause problems for testing are
Inheritance, Polymorphism and Encapsulation. We
studied the problems that are created by these
elements. A detailed study of the testing techniques
available to test programs developed under OO
environment have been made. Some of the
specialized techniques available to test OO software
have also been discussed.
9/18/16

43

8.References
Software Engineering: A Practitioners Approach, 7/e
by Roger S. Pressman
Prashant ,Int.J.Computer Technology &
Applications,Vol 3 (2), 746-749
Clarence J M Tauro, Testing Object-Oriented
Software Systems: A Survey of Steps and Challenges

9/18/16

44

Thank You

9/18/16

45

Potrebbero piacerti anche