Copyright Jehad Al-Dallal Software Testing

46
Copyright Jehad Al-Dallal Software Testing Department of Computing Science University of Alberta CMPUT 402 Software Engineering

description

 

Transcript of Copyright Jehad Al-Dallal Software Testing

Page 1: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Software Testing

Department of Computing Science

University of Alberta

CMPUT 402Software Engineering

Page 2: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Outlines Testing overview Testing object-oriented systems Testing object-oriented

frameworks Testing object-oriented framework

instantiations.

Page 3: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Testing Overview

Page 4: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Introduction Software testing

Verification activity Time consuming and costly. No correctness proof. Increase user confidence

Page 5: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Testing Phases Specification testing Design testing Implementation testing (software

testing) Dynamic Static

Page 6: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Test Suite

Testcase

Software test plan Document to explain testing approach

Testcase

Page 7: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Elements of a Test Case Reference number Description Preconditions Input Expected output

Page 8: Copyright Jehad Al-Dallal Software Testing

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”

Page 9: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Implementation testing levels Unit testing Integration testing System testing Regression testing

Page 10: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Unit testing Module testing Testing approaches

Black-box White-box

Page 11: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Example: problem statement

Given two integers, find the larger.If larger is less than 1, return 1.

Page 12: Copyright Jehad Al-Dallal Software Testing

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

….

Page 13: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

White-box testing Statement coverage Graph based

Branch coverage Condition coverage Path coverage

Page 14: Copyright Jehad Al-Dallal Software Testing

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

Page 15: Copyright Jehad Al-Dallal Software Testing

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

Page 16: Copyright Jehad Al-Dallal Software Testing

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

Page 17: Copyright Jehad Al-Dallal Software Testing

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

Page 18: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Integration Testing Non-incremental (big-bang) Incremental

Top-down (stubs needed) Bottom-up (drivers needed) Sandwich

Page 19: Copyright Jehad Al-Dallal Software Testing

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?

Page 20: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Regression Testing Ensuring that modifications have

not caused unintended effects. Retesting is required

Page 21: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Testing Object-Oriented Systems

Page 22: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Object-oriented testing Why it is different?

No sequential procedural executions. No functional decomposition. Unique problems

Encapsulation Inheritance Polymorphism

Page 23: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Object-oriented testing levels Method testing. Class testing. Cluster testing. System testing. Regression testing

Page 24: Copyright Jehad Al-Dallal Software 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.

Page 25: Copyright Jehad Al-Dallal Software Testing

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)

Page 26: Copyright Jehad Al-Dallal Software Testing

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;

}

Page 27: Copyright Jehad Al-Dallal Software Testing

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); … } …}

Page 28: Copyright Jehad Al-Dallal Software Testing

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

Page 29: Copyright Jehad Al-Dallal Software Testing

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.

Page 30: Copyright Jehad Al-Dallal Software Testing

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

Page 31: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Event Quiescence Atomic System Function (ASF):

Input Event Output EventMM-Path

Page 32: Copyright Jehad Al-Dallal Software Testing

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

Page 33: Copyright Jehad Al-Dallal Software Testing

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.

Page 34: Copyright Jehad Al-Dallal Software Testing

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

Page 35: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Testing Object-Oriented Frameworks

Page 36: Copyright Jehad Al-Dallal Software Testing

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.

Page 37: Copyright Jehad Al-Dallal Software Testing

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.

Page 38: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Framework testing Components (classes and small

clusters) black-box class associations

Hooks Compatibility and completeness Problem Solving

Page 39: Copyright Jehad Al-Dallal Software Testing

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 …

Page 40: Copyright Jehad Al-Dallal Software Testing

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

Page 41: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Testing Object-Oriented Framework Instantiations

Page 42: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Framework instantiation parts Framework used components. Interface components. Other instantiation components

Page 43: Copyright Jehad Al-Dallal Software Testing

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.

Page 44: Copyright Jehad Al-Dallal Software Testing

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

Page 45: Copyright Jehad Al-Dallal Software Testing

Copyright Jehad Al-Dallal

Summary Testing importance OO-technology effects testing. OO-Framework technology effect

testing.

Page 46: Copyright Jehad Al-Dallal Software 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