0% found this document useful (0 votes)
3 views33 pages

Testing of Object Oriented Systems

The document discusses the testing of Object-Oriented (OO) systems, highlighting the differences between OO and procedural programming, and the importance of integrating data and methods in testing. It covers various testing methods including unit testing, integration testing, and system testing, as well as concepts like encapsulation, polymorphism, and inheritance. Additionally, it outlines tools and techniques such as use cases, class diagrams, and sequence diagrams that aid in the testing process of OO systems.

Uploaded by

Vaibhav Ambekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views33 pages

Testing of Object Oriented Systems

The document discusses the testing of Object-Oriented (OO) systems, highlighting the differences between OO and procedural programming, and the importance of integrating data and methods in testing. It covers various testing methods including unit testing, integration testing, and system testing, as well as concepts like encapsulation, polymorphism, and inheritance. Additionally, it outlines tools and techniques such as use cases, class diagrams, and sequence diagrams that aid in the testing process of OO systems.

Uploaded by

Vaibhav Ambekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

Testing of Object Oriented

Systems
Differences in OO Testing
OO Language is Data or Object Centric. There is
no
separation between data & the methods that
operate on the data.
• Testing in OO systems should tightly integrate
data & algorithms.
• Testing in OO system covers following topics.
– Unit Testing a class
– Putting classes to work together (Integration
testing of classes)
– System testing
– Regression testing
– Tools for testing OO system
Procedural Programming
Procedure Oriented Software
The Procedure Oriented languages are
‘algorithm centric’.
They are characterized by
◦ Algorithms + Data Structures=Programs.
Object Oriented Software
 The Object Oriented languages are ‘Object centric’.
 Algorithm & Data are tightly coupled.
 Data & the methods operating on the data go
together as individual unit.
 Classes form the fundamental building blocks of OO
systems.
 Definition: Class : It is a representation of a real life
object.
 It provides a template that indicates the attributes &
methods of an object.
 Definition : Object: It is a real life entity made up of
attributes or variables & methods that operate on the
variables.
 All methods & properties of a class apply to all the
objects
MESSAGE PASSING
Objects communicate with each
other by sending & receiving
information.
A message for an object is a request
for execution of a procedure.
Message Passing involves specifying
the name of object, the name of the
function (msg.) & the information to
be sent.
Syntax : object . msg (info)
Object is an instance of a class.
Message passing: Objects communicate with
each other by sending & receiving information.
Message Passing involves specifying the name
of object, the name of the method (msg.) & the
information to be sent.
Syntax : object . msg (info)

Most classes have a method ‘new’, that creates


a new instance of a class.
Classes are instantiated by special member
function called Constructor.
Constructor : It is a special member function
that is called automatically when an object is
created. It initializes the data members of the
class.
Aclass can have multiple constructors.
A right constructor is called depending
on the parameters specified.
DATA ENCAPSULATION
• The wrapping up of data & functions into
a single unit is called as “Encapsulation”.
• It is a mechanism that associates the
code & the data. It manipulates and
keeps them safe from external interface
and misuse.
• Due to process of encapsulation data can
be accessed only by the functions that
are wrapped in the class.
The insulation of data from direct
program. access is called ‘Data Hiding’.
Polymorphism
It is the ability of a method or function to
take more than one form.
Multiple methods may have same name
but different behavior.
Function overloading: it is also called as
‘Function polymorphism’.
It is a concept that allows multiple
functions to share same name with
different argument type.
Ex :

void swap (int, int);


Void swap (float, float);
DYNAMIC BYNDING (LATE BINDING)
Bindingrefers to the linking of a
procedure call to the code to be
executed in response to the call.

Dynamic Binding means that the


code associated with the given
procedure call is not known until
the time of the call at run time.
INHERITANCE
It is a process by which a new class is
defined from existing class.
Some of the properties of a new class
are same as base class & some are
different.

DATA ABSTRACTION:
It refers to the act of representing
essential features without including
the background details.
The way the programs are written & tested
in OOP changes due to
◦ The paradigm shift from algorithm centric,
control based approach to Object-centric,
Message-based approach
◦ Messages passed to the objects that are not
instantiated, results in run-time errors. Such
errors are difficult to catch by the Static Method.
◦ Each class may have a set of errors that are
raised as error conditions.
◦ Transfer of code to these exceptions causes
break in the Program Sequence flow, which
needs to be tested.
◦ Nested classes may have nested exceptions.
Object’s interaction between the multiple levels
of testing should be proper and is difficult to
test.
Testing of OO Systems
Itbroadly covers the following
topics
1. Unit Testing a Class
2. Putting classes to work together
(Integration Testing of Classes)
3. System Testing
4. Regression Testing
5. Tools for testing OO system
Unit Testing a Set of Classes
Classes are the building blocks of the entire
OO systems.
They need to be unit tested before being put
together.
Need for testing the classes:
1. A class is intended for heavy reuse. Defects in a
class affects every reuse.
2. Many defects get introduced at the time of class
definition.
3. A class may have different features
4. Synchronization of data & methods should be unit
tested at the class level
5. Since OOP supports reuse through Inheritance,
building blocks should be thoroughly tested.
Conventional methods that apply to testing
the classes
Boundary Value analysis & Equivalence
Partitioning can be used to effectively test
data members.
Function Coverage: Ensures that every
method(function) is tested.
Condition Coverage, Branch Coverage,
Code complexity etc WBT techniques are
used to test the procedural logic of
methods.
Stress Testing can be performed to test
stress related problems due to multiple
instantiations of class by multiple clients.
Conventional methods that apply to testing
the classes
State Based Testing of BBT is the most
appropriate.
Special Considerations for testing the classes
To test the instantiated objects, messages
have to be passed to various methods.
To decide the sequence of message
passing, Alpha-Omega method is used.
Principles of Alpha-Omega method
1. Test the objects through their life cycle i.e.
From instantiation to destruction.
2. Test the simple methods first & then the
complex methods.
3. Test the methods from private through public.
4. Send a message to every method at least
once.
Alpha-Omega method has following steps
1. Test the constructors first. In case of multiple
constructors, test all.
2. Test the get methods or accessory methods-
Ensure variables in the class are accessed by
appropriate methods
3. Test the methods that modify object
variables. Test sequential, branching &
looping constructs for proper execution.
4. Test destruction of objects :
1. Call of destructors,
2. Releasing resources,
3. Ensure that no further accidental access is possible
Incremental Testing
 Inheritance makes Testing Complicated
 Following things are required to be tested :
1. Changes made to the base Class variables &
methods
2. New variables & methods in the derived class
Even the unchanged variables & methods needs
to be retested. The testing is decided as follows
3. Whenever an unmodified variable is referenced
in a new or modified method
4. Whenever an unmodified method is called in a
new or modified method.
Incremental Class Testing
 It is a method of testing all the changes
or new additions thoroughly at the point
of creation and selective re-testing of
other unchanged attributes.
 This solves
◦ the problem of exhaustive Testing
◦ Overcoming Risk
1. Multiple inheritance makes testing
challenging.
2. Interfaces or virtual class serve good
starting point for testing.
Putting Classes to work together – Integration
Testing
 OO systems are not a collection of discrete objs or
classes
 Objs or classes should co-exist, integrate and
communicate with one another.
 Hence testing that classes work together i.e. Integration
Testing is imp
 Differs from procedure oriented approach
 Can not use only method names to check sequence as
multiple methods have same defn but diffn
functionalities.
 Need to be tested according to the context.
 Challenges - Polymorphism
 Dynamic binding

Coverage testing of WBT will not be useful


Top Down or Bottom up will be applicable.
Tools for Testing of OO Systems
 Some of the tools that aid in testing
OO Systems.
1. Use Cases
2. Class Diagrams
3. Sequential Diagrams
4. State Charts
Integration Testing of OO
System
Points to be noted
◦ OO systems are built out of small
components, IT is more critical
◦ More parallelism in development of
comp, needs frequent IT.
◦ IT should be performed based on the
sequence of availability. May require
design of stubs to simulate yet-
unavailable classes.
System Testing and Interoperability
Heavy emphasis on reuse of existing building
blocks makes System Testing more imp
Points of importance-
◦ A class may have diff parts, Not all of them are
used at the same time.
◦ Different classes may be combined together by diff
clients
◦ An instantiated object may not free allocated
resources
◦ Imp to ensure that
 obj interoperate & work together
 Proper unit and comp testing is done
 Proper entry and exit criteria is set
Use Cases
 Use Cases represent the tasks
performed by the user while
interacting with the system.
 Consists of
◦ Users interaction with the system
◦ System Responses
 Suitable for OO paradigm as tasks &
responses are related to message
passing
Class Diagrams
 CD represents different entities & the
relationship between the entities.
 Parts of Class Diagram:
◦ Boxes: Represents Class containing Data
members & member functions
◦ Association: Represents relationship
between the classes by a line. Multiplicity
factor is shown on either side of the line.
◦ Generalization/ Specialization : Shown by
inheritance.
Uses of Class Diagrams
 Identifies elements of a class & hence
enables identification of BVA, EQ tests
 Association helps in identifying tests
for referential integrity constrains
across classes.
 Generalization helps in identifying
hierarchies & thus help in planning
Incremental class Test.
Sequence Diagram
 A SD represents a sequence of messages
passed among objects to accomplish a given
scenario
 Objects participating in a task are listed
horizontally.
 A lifeline of a object is represented by a
vertical line from top to bottom.
 A dashed line on top represents obj activation
& X sym at the end indicated obj distr.
 Messages are represented by horizontal lines
betn objs
 Time progresses from top to bottom.
Uses of Sequence Diagrams
It helps in testing by

 Identifying end to end messages.


 Tracing intermediate points in end to
end transactions.
 Providing message calling sequences
Activity Diagram
 A AD represents a sequence of act
 Used for modeling a typical work flow
 Brings out elements of interaction betn
manual & automated processes.
 Similar to a flow chart.
 Work flow is visualized as set of action
states
Uses of Activity Diagrams
It helps in testing

 Similar to flow graph in WBT in identifying


independent paths & calculate code complexity.
 Identify message flow betn act & obj

State Diagrams can be directly applied as in SBT of


BBT

You might also like