20
1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

  • View
    215

  • Download
    1

Embed Size (px)

Citation preview

Page 1: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

1

Software Testing and Quality Assurance

Lecture 24 – Testing Interactions

(Chapter 6)

Page 2: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

2

Lecture Outline To understand different types of

interactions. Learn techniques on how to select test

cases to run.

Page 3: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

3

Introduction Object-oriented program comprises a

collection of objects that collaborate to solve some problem.

Most classes have collaborators: The methods in the class interact with

instances of other classes.

Page 4: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

4

Introduction The interactions being tested are

between objects at runtime. The focus of interaction testing is

Ensuring that messaging occurs correctly with objects whose classes have already been tested separately.

Page 5: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

5

Object interactions An object interaction is simply

a request by one object (the sender) to another (the receiver) to perform one of the receiver’s operations; and

all of the processing performed by the receiver to complete the request.

Object interactions include: Messages between an object and its components Messages between an object and other objects

with which it is associated.

Page 6: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

6

Object interactions Partial class testing:

In an iterative, incremental development approach,

Classes are often developed in stages, these classes are tested to the extent that they are developed.

Page 7: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

7

Object interactions: identifying interactions

A primitive class is one that can be used without any collaboration with other objects (no need to create instances of any other

class). A nonprimitive class

is one that requires collaboration with other objects in order to accomplish its objectives.

Page 8: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

8

Object interactions: identifying interactions (cont...)

Possible collaborations: Parameter: public operation collaborates with an

object passed in as an argument (formal parameter).

Return: public operation returns an object with which it collaborates.

Internal: a method of a class creates an instance of another as part of its implementation.

Global: reference to a global instance of some class (undesired).

Page 9: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

9

Object interactions: identifying interactions (cont...)

Categories of nonprimitive classes based on degree of interaction: Collection classes: maintain references to

other classes, but do not collaborate (closely) with them.

Collaborating classes: interacts directly with its associated classes classes that are not collection classes.

Page 10: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

10

Object interactions: identifying interactions— collection classes

Collection classes: Use objects in their specifications but never actually collaborate with any of them; they never request any services from them.

Instead they do one of the following: Store references Create instances Delete instances

Examples: lists, stacks, and queues.

Page 11: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

11

Object interactions: identifying interactions— collaborating classes

Collaborating classes are: Non-primitive classes that are not

collection classes. They are classes that use other objects in

one or more operations as part of their implementation.

Page 12: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

12

Object interactions: identifying interactions— collaborating classes (cont...)

Factors that determine the size for testing: Composition and association:

During a class test, the interaction of the composing object with its composed attributes is tested.

The interaction between an object and its associated objects are tested as successive layers of aggregation are integrated.

Page 13: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

13

Object interactions: identifying interactions— collaborating classes (cont...)

The number of layers of aggregations created between interaction tests is closely related to the visibility of defects.

Object complexity: the more complex the objects, the fewer that should be integrated prior to a round of testing (number of parameters, methods,...).

Page 14: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

14

Testing object interactions: testing collection classes

Collection classes are tested using techniques for primitive classes: A test driver will create instances that are passed

as parameters in messages to a collection being tested.

Test cases center around ensuring that those instances are correctly incorporated into and removed from the collection class

If defensive design has been used then include negative test cases in the test suite

Page 15: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

15

Testing object interactions: testing collaborator classes

The complexity of testing a collaborating class is greater than that of testing a collection class or a primitive class.

For a collaborator class under test: Identify the collaborating classes Determine the sequence of testing

Collaborating classes, Next level of collaboration Then the next level of collaboration and so on

Page 16: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

16

Sampling test cases Population: all possible test cases that

can be executed A sample is a subset of a population

that has been selected based on some probability distribution.

Page 17: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

17

Sampling test cases Possibilities for determining which test cases

to select Based on probability distribution

A probability distribution defines, for each data value in a population, a set of allowable values and the probability that value will be selected.

Uniform probability distribution Each value in the population is assigned the same

selection probability Probability distribution based on the use profile

Page 18: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

18

Sampling test cases (cont...) A stratified sample is a set of samples

in which each sample represents a specific subpopulation Example: select a sample of test cases

from the use cases of each actor Stratified sample tests are selected from

a series of categories.

Page 19: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

19

Sampling test cases (cont...) Use of random number generator in sampling

Advantage: all values have equal probability Disadvantage: test cases cannot be

reproduced (you may let the test driver record the generated values)

Example Velocity class, set direction: values between 0 and 359

Class family: a set of classes related by inheritance.

Page 20: 1 Software Testing and Quality Assurance Lecture 24 – Testing Interactions (Chapter 6)

20

Key points Primitive and non-primitive classes. Possible collaborations: parameter, return,

internal, global. Categories of non-primitive classes: collection

and collaborating classes Factors that determine the size for testing

Composition and association: aggregations Object complexity