Al iqtisaad fi masyil e jehad by abul wahabia hussain batalvi
Copyright Jehad Al-Dallal Software Testing
-
Upload
softwarecentral -
Category
Documents
-
view
400 -
download
0
description
Transcript of Copyright Jehad Al-Dallal Software Testing
Copyright Jehad Al-Dallal
Software Testing
Department of Computing Science
University of Alberta
CMPUT 402Software Engineering
Copyright Jehad Al-Dallal
Outlines Testing overview Testing object-oriented systems Testing object-oriented
frameworks Testing object-oriented framework
instantiations.
Copyright Jehad Al-Dallal
Testing Overview
Copyright Jehad Al-Dallal
Introduction Software testing
Verification activity Time consuming and costly. No correctness proof. Increase user confidence
Copyright Jehad Al-Dallal
Testing Phases Specification testing Design testing Implementation testing (software
testing) Dynamic Static
Copyright Jehad Al-Dallal
Test Suite
Testcase
…
Software test plan Document to explain testing approach
Testcase
Copyright Jehad Al-Dallal
Elements of a Test Case Reference number Description Preconditions Input Expected output
Copyright Jehad Al-Dallal
Test Case (TC) ExampleTC#: S-221TC Description: This test is to check the
response to an invalid input selection.TC Precondition: Go to screen
Flight_ManagementTC Input: Enter <F7>TC Expected Output: Error message:
“Invalid input, Enter “1” to “4” or ESC”
Copyright Jehad Al-Dallal
Implementation testing levels Unit testing Integration testing System testing Regression testing
Copyright Jehad Al-Dallal
Unit testing Module testing Testing approaches
Black-box White-box
Copyright Jehad Al-Dallal
Example: problem statement
Given two integers, find the larger.If larger is less than 1, return 1.
Copyright Jehad Al-Dallal
Example: Black-box testing
Given two integers, find the largest.If largest is less than 1, return 1.
TC description TC Inputs
n1>n2 n1=2, n1=1
n1<n2 n1=1, n2=2
n1=n2 n1=n2=2
….
Copyright Jehad Al-Dallal
White-box testing Statement coverage Graph based
Branch coverage Condition coverage Path coverage
Copyright Jehad Al-Dallal
Example: Statement Coverage1 int maxPositive(int n1, int n2) {2 if (n1<=1 && n2<=1) 3 n1=1;4 if (n1<=n2) 5 n1=n2;
6 return n1; }
TC Inputs: n1=n2=1
Copyright Jehad Al-Dallal
Example: Branch Coverage1 int maxPositive(int n1, int
n2) {2 if (n1<=1 && n2<=1) 3 n1=1;4 if (n1<=n2) 5 n1=n2;
6 return n1; }
1,2
3
4
5
6
TC#2 Inputs: n1=2, n2=0TC#1 Inputs: n1=n2=1
Copyright Jehad Al-Dallal
Example: Condition Coverage1 int maxPositive(int n1, int
n2) {2 if (n1<=1 && n2<=1) 3 n1=1;4 if (n1<=n2) 5 n1=n2;
6 return n1; } TC#1 Inputs: n1=n2=1TC#2 Inputs: n1=2, n2=0
1,2
3
4
5
6
TC#3 Inputs: n1=0, n2=2
Copyright Jehad Al-Dallal
Example: Path Coverage1 int maxPositive(int n1, int
n2) {2 if (n1<=1 && n2<=1) 3 n1=1;4 if (n1<=n2) 5 n1=n2;
6 return n1; } TC#1 Inputs: n1=n2=1TC#2 Inputs: n1=2, n2=0
TC#3 Inputs: n1=0, n2=2
1,2
3
4
5
6
TC#4 Inputs: n1=n2=0
Copyright Jehad Al-Dallal
Integration Testing Non-incremental (big-bang) Incremental
Top-down (stubs needed) Bottom-up (drivers needed) Sandwich
Copyright Jehad Al-Dallal
System Testing Performed in terms of Inputs and
outputs of the system. Performed on the targeted platform. Goals:
Reveal bugs that are represented only at system level.
Demonstrate that the system implements all required capabilities.
Answer the question: Can we ship it yet?
Copyright Jehad Al-Dallal
Regression Testing Ensuring that modifications have
not caused unintended effects. Retesting is required
Copyright Jehad Al-Dallal
Testing Object-Oriented Systems
Copyright Jehad Al-Dallal
Object-oriented testing Why it is different?
No sequential procedural executions. No functional decomposition. Unique problems
Encapsulation Inheritance Polymorphism
Copyright Jehad Al-Dallal
Object-oriented testing levels Method testing. Class testing. Cluster testing. System testing. Regression testing
Copyright Jehad Al-Dallal
Class testing Tests classes by sending messages
to methods one at a time. Requires drivers and stubs. May have to test more than one
method at a time to test the collaboration of methods.
Inherited method have to be tested.
Copyright Jehad Al-Dallal
Alpha-Omega Cycle Class Testing Alpha state: object declaration state. Omega state: object destruction state. Alpha-omega cycle testing: takes
objects from alpha to omega states by sending messages to every method at least once.
Method ordering (constructor, accessor, predicate, modifier, destructor)
Copyright Jehad Al-Dallal
ExampleClass person { person(String n, int a) { name=n; age=a; } constructor void setName(String n) { name=n; } modifier void setAge(int a) { age=a; } modifier String getName() { return name; } accessor int getAge() { return age; } accessor int isOld() { if age>50 return 1; return 0;} predicate String name; int age;
}
Copyright Jehad Al-Dallal
Example (Cont’d)Class driver { … void test() { person Tom= new Tom(“Tom”, 20); String name=Tom.getName(); int a=Tom.getAge(); if (Tom.isOld()) { … } setName(“old Tom!!”); setAge(60); … } …}
Copyright Jehad Al-Dallal
Cluster testing Cluster: collection of classes
cooperating with each other via messages.
Goal: test the interaction among the objects of the classes that forms the cluster.
Techniques: Message Quiescence Event Quiescence
Copyright Jehad Al-Dallal
Message Quiescence Method/Method path (MM-Path):
sequence of method executions linked by messages.
Starts with a method and ends with another method that does not issue a message.
Copyright Jehad Al-Dallal
meth1
meth3meth2
Class 1
meth1 meth3
meth2
meth2
meth1
Class 2
Class 3
Message
1
2
3
Event
MM-Path
MM-Paths
Copyright Jehad Al-Dallal
Event Quiescence Atomic System Function (ASF):
Input Event Output EventMM-Path
Copyright Jehad Al-Dallal
meth1
meth3meth2
Class 1
INPUT PORT EVENT
INPUT PORT EVENT
OUTPUT PORT EVENTA
A
meth1 meth3
meth2
meth2
meth1
BB
OUTPUT PORT EVENT
Class 2
Class 3
MM-Path
Message
1
2
3
Event
Copyright Jehad Al-Dallal
Example ATM pin entry
Customer enters card (event). Card is validated. Screen requesting pin entry is
displayed. Digits are touched and displayed. Pin is checked.
Copyright Jehad Al-Dallal
getKeyEvents
parseKeyEvent
showMessage
checkPin
memberCard
ValidateCard
Security
Screen CardSlot
NumKeypad
Customer inserts cardASF Starts here
Message is displayed
ASF ends here
Key pushers
Copyright Jehad Al-Dallal
Testing Object-Oriented Frameworks
Copyright Jehad Al-Dallal
Definitions OO-Framework
Reusable design and implementation of a system or subsystem [Beck+ 94]
Design + code + hooks Hooks
Places at which users can add their own components.
Copyright Jehad Al-Dallal
Importance Why do we have to care about
testing frameworks? Framework defects passes on to all
instantiations. Hard to discover framework defects at
the instantiation development stages. Little research has been carried out.
Copyright Jehad Al-Dallal
Framework testing Components (classes and small
clusters) black-box class associations
Hooks Compatibility and completeness Problem Solving
Copyright Jehad Al-Dallal
Testing OO-framework Problems Testing framework implementation
Developing testable model for the framework specifications.
Developing a test suite generator technique.
Testing framework hooks …
Copyright Jehad Al-Dallal
Testing OO-framework Problems (Cont’d) Testing framework hooks
Formalizing hook requirements. Developing testable model for hook
methods. Integrating hook method model with
framework specification model. Extending framework implementation test
suite generator technique. Developing an approach to test hook
compatibility and completeness
Copyright Jehad Al-Dallal
Testing Object-Oriented Framework Instantiations
Copyright Jehad Al-Dallal
Framework instantiation parts Framework used components. Interface components. Other instantiation components
Copyright Jehad Al-Dallal
Importance Why do we have to deal with
framework instantiations in a special way? Part of the code is tested. Part of the code is not needed. Part of the code is extended.
Copyright Jehad Al-Dallal
Testing framework instantiation problems Testing the used portion of the
framework code. Testing the extensibility of the
framework. Testing the framework interfaces. Testing other instantiation
components. Integration testing
Copyright Jehad Al-Dallal
Summary Testing importance OO-technology effects testing. OO-Framework technology effect
testing.
Copyright Jehad Al-Dallal
References G. Myers, The art of software testing, Wiley-
Interscience, 1979. B. Beizer, Software Testing Techniques, Van
Nostrand reinhold, 2nd edition, 1990. R. Binder, Testing object-oriented systems,
Addison Wesley, 1999. M. Hanna, Testing object-oriented systems for
QA professionals, PSQT/PSTT 2000 North Minneapolis, MN, conference tutorial H4, 2000.
M. Petchiny, Object-oriented testing, http://www.cs.queensu.ca/home/shepard/599.dir/petchiny/OOPRESENTATION.ppt