This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Slide 3 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
Overview
• Why is testing object-oriented software difficult?• Specification and testing of object-oriented software• The UML Testing Profile • TTCN-3 cases for OO
Slide 4 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
which fails observably
Failure
Why do we test?
• Errare humanum est! (to err is human)• Even with formal specification and
program generation ...– Spec could be wrong– Generator doesn‘t work as expected– Platform doesn‘t work as expected– ...
• Testing checks that the Software– ... does what it should do and ...– ... doesn‘t what it shouldn‘t do
• But always remember that ...– ... „testing can only show the presence
of faults (i.e. bugs), not their absence“!!! [E.W. Djikstra]
Fault
in some program
Error
of a person
Why is testing OO-SW difficult?Specification and testing of OO-SW
• Encapsulation– Bundling of data with the operations that manipulate that data– Classes often hide encapsulated information by presenting only public interfaces
• Inheritance– Forms new classes using already defined classes– Generalization: is-a relationship, captures hierarchical relationship between classes
• Polymorphism – Ability of object (references) belonging to different classes to respond to calls of
operations of the same name, each one according to a class-specific behavior– Programmer (and program) doe not have to know the exact classes of objects in
advance, so behavior can be implemented in different ways• Late binding (aka. dynamic binding)
– At run time, the machine (“system”) decides which method to execute– Methods searched upwards the inheritance hierarchy
Why is testing OO-SW difficult?Specification and testing of OO-SW
The UML Testing ProfileTTCN-3 cases for OO
Slide 10 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Slide 11 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
Hierarchical Inheritance Testing (HIT)
Create new test casesExecute new test cases
Create new test casesExecute new test cases
Repeat test cases of superclass
White-box test cases
Create new test casesExecute new test cases
New defined operations
Complement test casesExecute test cases of superclass and complementedtest cases
Redefined operations(Pure generalization)
Execute test cases of superclassInherited operations
Black box test casesOperations of subclass
Slide 12 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
Where are we now?
• Why is testing object-oriented software difficult?• Specification and testing of object-oriented software• The UML Testing Profile • TTCN-3 cases for OO
Slide 15 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
Specification of interfaces with assertions
• Precondition (of an operation)– States the properties that must hold whenever the operation is called.– Refers to input-parameters of the operation und the state of the component
• Postcondition (of an operation)– States the properties that the operation guarantees when it returns (assuming its
precondition was satisfied) – Refers to output-parameters of the operation und the state of the component
• Both preconditions and postconditions describe properties of individual operations –but often there are more general properties
• Invariant (of the class)– Expresses global properties of all instances of a class, which must be preserved by all
operations– Refers to the state / instant variables of the class– Must be satisfied before and after each execution of each (public) operation
Why is testing OO-SW difficult?Specification and testing of OO-SW
The UML Testing ProfileTTCN-3 cases for OO
Slide 16 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
Example: BoundedStack (Stack with bounded capacity)
2 ← size1
MAXSIZE
class BoundedStackState preserving operations
size():integer; // Number of elementsMAXSIZE(): integer; // Maximum count of elementstop():Object; // Pointer to topmost element
State changing operationsBoundedStack(maxSize: integer);// Constructor~BoundedStack(); // Destructorpush(element: Object); // Stack element on toppop(); // Removes topmost element
class BoundedStackState preserving operations
size():integer; // Number of elementsMAXSIZE(): integer; // Maximum count of elementstop():Object; // Pointer to topmost element
State changing operationsBoundedStack(maxSize: integer);// Constructor~BoundedStack(); // Destructorpush(element: Object); // Stack element on toppop(); // Removes topmost element
push(element: Object)3 ← size21pop()
top():Object
Why is testing OO-SW difficult?Specification and testing of OO-SW
Slide 21 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
Testing operation calls and late binding
Am1(){myB.m2();}
B1m2(){...}
B2m2(){...}
m2(aB: B){...}
A2A1
myBB
Operating object (as „client"), parameter object und server object classes:How many different combinations of classes and states?Operating object (as „client"), parameter object und server object classes:How many different combinations of classes and states?
OpUTOpUT
CallCall
Parameter classParameter classClient classClient class
Server classServer class
Two states SA1 and SA2Two states SA1 and SA2
Three States SB1, SB2 and SB3
Three States SB1, SB2 and SB3
(3 C * 2 S) * (3 C * 3 S) * (3 C * 3 S) = 486 possibilities!(3 C * 2 S) * (3 C * 3 S) * (3 C * 3 S) = 486 possibilities!
Why is testing OO-SW difficult?Specification and testing of OO-SW
The UML Testing ProfileTTCN-3 cases for OO
Slide 22 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
Idea: Not all combinations, but all pairwise combinations• Orthogonal arrays (OA)• 2 x 3 classes with 2 resp. 3 states!• 6 factors with cardinality 2 resp 3
Slide 25 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
Where are we now?
• Why is testing object-oriented software difficult?• Specification and testing of object-oriented software• The UML Testing Profile• TTCN-3 cases for OO
Slide 26 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
Example: Automated Teller Machine (ATM)
System Under Test(SUT)ATM
Main Test Component
(MTC)
Bank User
Parallel TestComponent
(PTC)
Bank ServerUser
InterfaceNetworkInterface
Test Coordination
Test System
Why is testing OO-SW difficult? Specification and testing of OO-SW
The UML Testing ProfileTTCN-3 cases for OO
NetworkInterface
UserInterface
Bank ServerBank User at ATM
Ina Schieferdecker: The UML 2.0 Testing Profile. Proc. TAV 19, Erlangen, 2003
Why is testing OO-SW difficult? Specification and testing of OO-SW
The UML Testing ProfileTTCN-3 cases for OO
Slide 30 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
Where are we now?
• Why is testing object-oriented software difficult? • Specification and testing of object-oriented software• The UML Testing Profile • TTCN-3 cases for OO
Slide 31 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
TTCN-3 – The standard
Why is testing OO-SW difficult? Specification and testing of OO-SW
The UML Testing Profile TTCN-3 cases for OO
Presentation Format n
Graphical Format
Tabular Format
Other Types & Values 2
IDL
ASN.1 Types & Values
Other Types & Values n
Presentation Format nUML Testing Profile
…
C++
msc mi_synch1_conc1
mtc ISAP1 MSAP2
TTCN-3CoreLanguage
:testcase myTestcase () runs on MTCType system TSIType{ mydefault := activate (OtherwiseFail);
verdict.set(pass);:connect(PTC_ISAP1:CP_ISAP1,mtc:CP_ISAP1);:map(PTC_ISAP1:ISAP1, system:TSI_ISAP1);:PTC_ISAP1.start(func_PTC_ISAP1());PTC_MSAP2.start(func_PTC_MSAP2());Synchronization(); all component.done;log(”Correct Termination”);
}:
Slide 32 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
Eclipse Test & Performance Tools Platform (TPTP)
• Object oriented testing with TTCN-3• Open source top level project of the Eclipse foundation• Includes the HYADES TTCN-3 tool set
– TTCN-3 Core Language Editor– TTCN-3 Compiler
• TPTP is divided into four projects. – TPTP Platform – Monitoring Tools– Testing Tools– Tracing and Profiling Tools
• But– TTCN-3 integration with least common denominator principle – Many powerful TTCN-3 concepts were left out!
http://www.eclipse.org/tptp
Why is testing OO-SW difficult? Specification and testing of OO-SW
Slide 33 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
Using C/C++ with TTCN-3
• Draft ETSI ES 201 873-10 Methods for Testing and Specification (MTS); The Testing and Test Control Notation version Part 10: Using C/C++ with TTCN-3 (lead author: Jens Grabowski)
Why is testing OO-SW difficult? Specification and testing of OO-SW
The UML Testing Profile TTCN-3 cases for OO
Slide 34 Prof. Dr. Mario Winter, FH KölnTTCN3UC Berlin 2006
Object-Oriented Testing meets TTCN-3
What did we reach with TTCN-3?
• OO-Testing = Message Sequences = TTCN-3• Excellent notation for black-box test scripts
– Modular– Reusable
• Excellent tool support for TTCN-3 specification and execution– Commercial and open source– Different domains (communication, automotive, web, ...) well covered
Why is testing OO-SW difficult? Specification and testing of OO-SW