8/8/2019 20061202 Gawn Issues in Object Oriented Testing
1/21
8/8/2019 20061202 Gawn Issues in Object Oriented Testing
2/21
IntroductionOverview of Object Orientated Unit Testing
Implications of Object Oriented TestingSummary
What am I going to talk about?The Object Orientated Paradigm
What am I going to talk about?
A little background of object orientated programming
Unit testing issues Implications various object orientated properties:
Composition and Encapsulation Inheritance Polymorphism
Levels of object orientated testing
A quick round up
James Gawn Issues in Object-Oriented Testing
http://goforward/http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
3/21
IntroductionOverview of Object Orientated Unit Testing
Implications of Object Oriented TestingSummary
What am I going to talk about?The Object Orientated Paradigm
The Object Orientated Paradigm
Started way back in 1960s with PDP-1 System from MIT
Smalltalk in the 1980s influnced the introduction of the idea
of inheritance Became more widely used in 1990s with advent of C++
Promised to make code reuse easier
Unfortunately does introduce a new set of issues for testing
Treats programming as a series of co-operating objects,opposed to collections of functions
James Gawn Issues in Object-Oriented Testing
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
4/21
IntroductionOverview of Object Orientated Unit Testing
Implications of Object Oriented TestingSummary
Units in an object orientated system?AdvantagesDisadvantages
Overview of Object Orientated Unit Testing
James Gawn Issues in Object-Oriented Testing
I d i
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
5/21
IntroductionOverview of Object Orientated Unit Testing
Implications of Object Oriented TestingSummary
Units in an object orientated system?AdvantagesDisadvantages
What is a unit in an object orientated system?
What is a unit in an object orientated system? Traditional systems define a unit as the smallest component
that can be compiled and executed Units are normally a component which in theory is only ever
assigned to one programmer
Two options for selecting units in object orientated systems: Treat each class as a unit Treat each method within a class as a unit
James Gawn Issues in Object-Oriented Testing
I t d ti
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
6/21
IntroductionOverview of Object Orientated Unit Testing
Implications of Object Oriented TestingSummary
Units in an object orientated system?AdvantagesDisadvantages
Advantages for Object Orientated Unit Testing
Once a class is testing thoroughly it can be reused without
being unit tested again UML class state charts can help with selection of test cases
for classes
Classes easily mirror units in traditional software testing
James Gawn Issues in Object-Oriented Testing
Introduction
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
7/21
IntroductionOverview of Object Orientated Unit Testing
Implications of Object Oriented TestingSummary
Units in an object orientated system?AdvantagesDisadvantages
Disadvantages for Object Orientated Unit Testing
Classes obvious unit choice, but they can be large in someapplications
Problems dealing with polymorphism and inheritance
James Gawn Issues in Object-Oriented Testing
Introduction
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
8/21
IntroductionOverview of Object Orientated Unit Testing
Implications of Object Oriented TestingSummary
Implications of Composition and EncapsulationImplications of Inheritance and PolymorphismLevels of OO Testing
Implications of Composition and Encapsulation
James Gawn Issues in Object-Oriented Testing
IntroductionC
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
9/21
IntroductionOverview of Object Orientated Unit Testing
Implications of Object Oriented TestingSummary
Implications of Composition and EncapsulationImplications of Inheritance and PolymorphismLevels of OO Testing
Composition Issues
Objective of OO is to facilitate easy code reuse in the form ofclasses
To allow this each class has to be rigiriously unit tested Due to classes potentially used in unforeseeable ways when
composed in new systems Example: A XML parser for a web browser
Classes must be created in a way promoting loose couplingand strong cohesion
James Gawn Issues in Object-Oriented Testing
IntroductionI li i f C i i d E l i
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
10/21
IntroductionOverview of Object Orientated Unit Testing
Implications of Object Oriented TestingSummary
Implications of Composition and EncapsulationImplications of Inheritance and PolymorphismLevels of OO Testing
Encapsulation Issues
Encapsulation requires that classes are only aware of their ownproperties, and are able to operate independently
If unit testing is performed well, the integration testingbecomes more important
If you do not have access to source code then structuraltesting can be impossible
If you violate encapsulation for testing purposes, then thevalidity of test could be questionable
James Gawn Issues in Object-Oriented Testing
IntroductionI li ti f C iti d E l ti
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
11/21
Overview of Object Orientated Unit TestingImplications of Object Oriented Testing
Summary
Implications of Composition and EncapsulationImplications of Inheritance and PolymorphismLevels of OO Testing
Implications of Inheritance and Polymorphism
James Gawn Issues in Object-Oriented Testing
IntroductionImplications of Composition and Encapsulation
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
12/21
Overview of Object Orientated Unit TestingImplications of Object Oriented Testing
Summary
Implications of Composition and EncapsulationImplications of Inheritance and PolymorphismLevels of OO Testing
The Issues
Inheritance is an importantpart of the object orientedparadigm
Unit testing a class with asuper class can beimpossible to do without thesuper classesmethods/variables
James Gawn Issues in Object-Oriented Testing
IntroductionImplications of Composition and Encapsulation
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
13/21
Overview of Object Orientated Unit TestingImplications of Object Oriented Testing
Summary
Implications of Composition and EncapsulationImplications of Inheritance and PolymorphismLevels of OO Testing
One Solution - Flattening
Merge the super class, and the class under test so allmethods/variables are available
Solves initial unit test problems Problems:
The class wont be flattened in the final product so potentialissues may still arise
Complicated when dealing with multiple inheritance
James Gawn Issues in Object-Oriented Testing
IntroductionO i f Obj O i d U i T i
Implications of Composition and Encapsulation
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
14/21
Overview of Object Orientated Unit TestingImplications of Object Oriented Testing
Summary
Implications of Composition and EncapsulationImplications of Inheritance and PolymorphismLevels of OO Testing
One Solution - Flattening
James Gawn Issues in Object-Oriented Testing
IntroductionO i f Obj t O i t t d U it T ti
Implications of Composition and Encapsulation
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
15/21
Overview of Object Orientated Unit TestingImplications of Object Oriented Testing
Summary
Implications of Composition and EncapsulationImplications of Inheritance and PolymorphismLevels of OO Testing
Polymorphism Issues
Repeatedly testing samemethods
Time can then be wasted if
not addressed Potentially can be avoided,
and actually save time
James Gawn Issues in Object-Oriented Testing
IntroductionO e ie of Object O ie tated U it Testi g
Implications of Composition and Encapsulation
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
16/21
Overview of Object Orientated Unit TestingImplications of Object Oriented Testing
Summary
p p pImplications of Inheritance and PolymorphismLevels of OO Testing
Polymorphism Issues - Example Diagram
James Gawn Issues in Object-Oriented Testing
IntroductionOverview of Object Orientated Unit Testing
Implications of Composition and Encapsulation
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
17/21
Overview of Object Orientated Unit TestingImplications of Object Oriented Testing
Summary
p p pImplications of Inheritance and PolymorphismLevels of OO Testing
Polymorphism Issues - Example Code
James Gawn Issues in Object-Oriented Testing
IntroductionOverview of Object Orientated Unit Testing
Implications of Composition and Encapsulation
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
18/21
Overview of Object Orientated Unit TestingImplications of Object Oriented Testing
Summary
Implications of Inheritance and PolymorphismLevels of OO Testing
Levels of Object Orientated Test
There are generally 3 or 4 levels of testing for object orientated
systems depending on your approach, consisting of:1. Method Testing (Unit Testing)2. Class Testing (Unit Testing/Intraclass Testing)3. Interclass Testing (Integration Testing)4. System Testing
James Gawn Issues in Object-Oriented Testing
IntroductionOverview of Object Orientated Unit Testing
A Q i k R d
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
19/21
Overview of Object Orientated Unit TestingImplications of Object Oriented Testing
Summary
A Quick Roundup
Summary
James Gawn Issues in Object-Oriented Testing
IntroductionOverview of Object Orientated Unit Testing
A Q i k R d
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
20/21
O e e o Object O e tated U t est gImplications of Object Oriented Testing
Summary
A Quick Roundup
A Quick Roundup
Object orientated testing is a pain Encapsulation Inheritance Polymorphism
Necessary evil as it is more widely adopted
Light at the end of the tunnel is unit/class reuse
James Gawn Issues in Object-Oriented Testing
IntroductionOverview of Object Orientated Unit Testing
A Quick Roundup
http://find/http://goback/8/8/2019 20061202 Gawn Issues in Object Oriented Testing
21/21
j gImplications of Object Oriented Testing
Summary
A Quick Roundup
Issues in Object-Oriented Testing
Testing Extravaganza Weekend
James Gawn
02.12.2006
James Gawn Issues in Object-Oriented Testing
http://find/http://goback/Top Related