+ All Categories
Home > Documents > 09 OO Testing and Test Cases

09 OO Testing and Test Cases

Date post: 22-Apr-2015
Category:
Upload: softwarecentral
View: 1,726 times
Download: 2 times
Share this document with a friend
Description:
 
32
1 OO testing and testing strategies Testing object-oriented software Testing strategies Higher-order testing
Transcript
Page 1: 09 OO Testing and Test Cases

1

OO testing and testing strategies

• Testing object-oriented software

• Testing strategies

• Higher-order testing

Page 2: 09 OO Testing and Test Cases

2

Object - oriented testing

• begins by evaluating the correctness and consistency of the OOA and OOD models

• testing strategy changesthe concept of the ‘unit’ broadens due to encapsulation

integration focuses on classes and their execution across a ‘thread’ or in the context of a usage scenario

validation uses conventional black box methods

• test case design draws on conventional methods, but also encompasses special features

Page 3: 09 OO Testing and Test Cases

3

OOT strategy

• classes are the smallest testable unit

• inheritance defines new context for methods– behavior of inherited methods can be changed because of methods that are

called within

– methods have to be tested per class

• objects have states: testing methods have to take that into account

• class testing is the equivalent of unit testing– operations within the class are tested

– the state behavior of the class is examined

• OO testing concentrates on the states of the objects and their interactions

Page 4: 09 OO Testing and Test Cases

4

Integration applied three different strategies

• thread-based testing• integrates the set of classes required to respond to one

input or event

• use-case based testing• integrates the set of classes required to respond to one use

class

• starts with independent (ground) classes

• cluster testing• integrates the set of classes required to demonstrate one

collaboration

Page 5: 09 OO Testing and Test Cases

5

OOT - test case design (1)

Berard [BER93] proposes the following approach:

1. each test case should be uniquely identified and should be explicitly associated with the class to be tested,

2. the purpose of the test should be stated,

3. a list of testing steps should be developed for each test and should contain [BER94]:

Page 6: 09 OO Testing and Test Cases

6

OOT - test case design (2)

A a list of specified states for the object that is to be tested

B a list of messages and operations that will be exercised as a consequence of the test

C a list of exceptions that may occur as the object is tested

D a list of external conditions (i.e., changes in the environment external to the software that

must exist in order to properly conduct the test)

E supplementary information that will aid in understanding or implementing the test.

Page 7: 09 OO Testing and Test Cases

7

Problems in testing OO software

• Testing shall report errorsinternal state of object

• Encapsulation hides internal things

• Inheritance: test cases of the superclass may may have to be adapted

Page 8: 09 OO Testing and Test Cases

8

OOT methods: Scenario-based testing

• Concentrates on what the user does NOT what the system does

• Based on use cases

• Described by– a test– specific user needs

Page 9: 09 OO Testing and Test Cases

9

OOT methods: random testing

• random testingidentify operations applicable to a class

define constraints on their use

identify a minimum test sequence• an operation sequence that defines the minimum

life history of the class (object)

generate a variety of random (but valid) test sequences

• exercise other (more complex) class instance life histories

Page 10: 09 OO Testing and Test Cases

10

OOT methods: partition testing (1)

• Partition testingreduces the number of test cases required to

test a class in much the same way as equivalence partitioning for conventional software

state-based partitioning• categorize and test operations based on their

ability to change the state of a class

Page 11: 09 OO Testing and Test Cases

11

OOT methods: partition testing (2)

• Partition testingattribute-based partitioning

• categorize and test operations based on the attributes that they use

category-based partitioning• categorize and test operations based on the

generic function each performs e.g.– initialization

– state changing

– queries

– termination

Page 12: 09 OO Testing and Test Cases

12

State diagram based testing

• Use state diagram to determine a sequence of events

• Tests should achieve all state coverage

• All transitions should be tested at least once

• Test invalid events

Page 13: 09 OO Testing and Test Cases

13

OOT methods: Inter-class testing (1)

• Inter-class testingFor each client class, use the list of class

operators to generate a series of random test sequences. The operators will send messages to other server classes.

For each message that is generated, determine the collaborator class and the corresponding operator in the server object.

Page 14: 09 OO Testing and Test Cases

14

OOT methods: Inter-class testing (2)

• Inter-class testingFor each operator in the server object ( that

has been invoked by messages sent from the client object), determine the messages that it transmits.

For each of the messages, determine the next level of operators that are invoked and incorporate these into the test sequence

Page 15: 09 OO Testing and Test Cases

15

OO testing and testing strategies

• Testing object-oriented software

• Testing strategies

• Higher-order testing

Page 16: 09 OO Testing and Test Cases

16

Verification & validation

• Verification: Are we building the product right

• Validation: Are we building the right product

Page 17: 09 OO Testing and Test Cases

17

Testing strategy

code

design

requirementshigh-order

tests

integration test

unittest

Page 18: 09 OO Testing and Test Cases

18

Unit testing

Test cases

Moduleinterface

local data structures

boundary conditions

independent paths

error handling paths

Page 19: 09 OO Testing and Test Cases

19

Unit testing environment

Test cases

interface

local data structures

boundary conditions

independent paths

error handling paths

driver

Module

stub stub

RESULTS

Page 20: 09 OO Testing and Test Cases

20

Why integration testing?

• If all units work individually, why doubt that they work together?

• Putting units together - interfacing

Page 21: 09 OO Testing and Test Cases

21

Integration testing

BigBang!

incrementalconstruction

strategy

incremental“builds”

regressiontesting

Page 22: 09 OO Testing and Test Cases

22

Top down integration

A

GFB

E

C

D

top module is tested with stubs

stubs are replaced one at a time, “depth first”

as new modules are integrated,some subset of tests is re-run

Page 23: 09 OO Testing and Test Cases

23

Bottom-up integration

A

GFB

E

C

D

drivers are replaced one at a time, “depth first”

worker modules are grouped intobuilds and integrated

cluster

Page 24: 09 OO Testing and Test Cases

24

Sandwich testing

A

GFB

E

C

Dworker modules are grouped intobuilds and integrated

cluster

top modules are tested with stubs

Page 25: 09 OO Testing and Test Cases

25

OO testing and testing strategies

• Testing object-oriented software

• Testing strategies

• Higher-order testing

Page 26: 09 OO Testing and Test Cases

26

High-order testing

• validation test

• system test

• alpha and beta test

• other specialized testing

Page 27: 09 OO Testing and Test Cases

27

Alpha & Beta test

software

developer site customer site

customer tests

Alpha test

software

developer site customer site

customertests

Beta test

developerreviews

Page 28: 09 OO Testing and Test Cases

28

Test specification (1)

1. Scope of testing

2. Test plan

3. Test procedure n (description of test for build n)

4. Actual test results

5. References

6. Appendices

Page 29: 09 OO Testing and Test Cases

29

Test specification (2)

2. Test planA. test phases and builds

B. schedule

C. overhead software

D. environment and resources

Page 30: 09 OO Testing and Test Cases

30

Test specification (3)

3. Test procedure n A. order of integration

1. purpose

2. modules to be tested

B. unit tests for modules in build1. description of tests for module n

2. overhead software description

3. expected results

Page 31: 09 OO Testing and Test Cases

31

Test specification (4)

3. Test procedure n C. test environment

1. special tools or techniques

2. overhead software description

D. test case data

E. expected results for build n

Page 32: 09 OO Testing and Test Cases

32

Debugging: Symptoms & causes

• Symptom and cause may be geographically separated

• symptom may disappear when another problem is fixed

• cause may be due to a combination of non-errors

• cause may be due to a system or compiler error

• cause may be due to assumptions that everyone believes

• symptom may be intermittentcausesymptom


Recommended