Docsity

Verification and Validation - Testing Methods - Project | CS 451, Study Guides, Projects, Research of Software Engineering

Partial preview of the text

Download Verification and Validation - Testing Methods - Project | CS 451 and more Study Guides, Projects, Research Software Engineering in PDF only on Docsity!

Verification and Validation — Testing Methods

CS 451/

Old Dominion University

Steven J. Zeil

Spring 1999

Verification and Validation

  1. Static Verification
  2. Testing
  3. Automated Aids for Testing

1

1 Testing

Basic approaches:

  1. Representative testing1. Test with data representative of the way in which the program will be used.
  2. Directed testing1. Test with data designed to reveal faults

2

Why do we test?

To show that the program works

To reveal faults

To gain confidence in the program

1.1 Representative testing

Choose data that is representative of the way the end users will exer- cise the software.

Advantages:

- realism — catches the kinds of failures that the users would have encountered - relatively cheap to generate tests - time to failure during test reflects time to failure in opera- tion

useful in statistical reliability modeling

4

  1. Producing Representative Tests1.1.
  2. Reliability Growth Models1.1.

5

1.1.1 Producing Representative Tests

collected data from existing system

- further selection may be needed - cannot accomodate new functionality

random generators

- non-uniform, to match desired distribution - can be hard to generate non-numeric ADT values

6

Representative Testing

Requires operational profile for its definition

- The operational profile defines the expected pattern of soft- ware usage

7

Sample Op Profile Input Category Percentage Transaction Proc. 85% New account 7% new 90% already exists 10% Close account 15% non-existant 15% exists 85% Debits 70% non-existant 25% exists 75% check 80% ATM fee 15% service fee 4.5% .. . Credits 20% non-existant 25% exists 75% Balancing 14% Year-end Report 1% 8

Numeric Op Profiles For numeric quantities, operational profile may give a distribution , indicate the probability of a value falling in a given range.

9

Reliability measurement

Measure the number of system failures for a given number of

system inputs

- Used to compute POFOD

Measure the time (or number of transactions) between system

failures

- Used to compute ROCOF and MTTF

Measure the time to restart after failure

- Used to compute Avail

17

Time units

Time units in reliability measurement must be carefully selected.

Not the same for all systems

Raw execution time (for non-stop systems)

Calendar time (for systems which have a regular usage pattern

e.g. systems which are always run once per day)

Number of transactions (for systems which are used on demand)

Jelinski-Moranda Model Assumptions:

Software contains  faults (  is unknown)

Each fault manifests (causes a failure) at rate 

Faults manifest independently

Faults are fixed perfectly, without introducing new ones

If we have repaired faults, the program’s failure rate  is

Observed reliability growth

Simple equal-step model but does not reflect reality

Reliability does not necessarily increase with change as the

change can introduce new faults

The rate of reliability growth tends to slow down with time as

frequently occurring faults are discovered and removed from the software

20

Musa Logarithmic Poisson Model Assumptions:

Software can never be completely free of faults.

Faults manifest independently

Faults are found in decreasing order of failure rate.

The program failure rate before repairing any faults is !

Faults are fixed perfectly, without introducing new ones

If we have repaired  faults, the program’s failure rate  is

Fitting Example

1e-

1e-

1

0 5 10 15 20 25 30 35

Failure Rate

Failure Number

LSq Fit - Sequence 2 Representative JM ML

1.2 Directed testing

Chhose tests designed to reveal

many faults

as quickly as possible

Testing methods are classified by whether they require information about the implementation.

  1. Black-Box Testing1.2.
  2. White-Box Testing1.2.

We will also consider

  1. Reliability Modeling with Directed Tests1.2.

24

1.2.1 Black-Box Testing

Black-box (a.k.a. specification-based ) testing chooses tests without consulting the implementation.

Equivalence partitioning

Boundary-value testing

Special-values testing

Equivalence Partitioning (a.k.a functional testing )

Attempt to choose test data illustrating each distinct behavior or

each distinct class of inputs and outputs at least once.

- e.g., each kind of transaction, each kind of report

Can be driven by function points.

Boundary-Values Testing Choose data at the boundaries of a functional testing class or of the overall input domain.

check amount ")

check amount *,+.-/0) )) /0)) )

transaction date  day before bank was founded

transaction date 100 years in future

name string empty

name string one less than full

name string full

name string overfull

Special-Values Testing Choose data reflecting “special” or troublesome cases. Examples include choosing for

each numeric input

- negative, - zero, and - positive values,

each string input

- empty - entirely blank strings,

etc.

28

1.2.2 White-Box Testing

White-Box (a.k.a. Implementation-based testing) uses information from the implementation to choose tests.

Structural Testing (a.k.a., “path testing” (not per your text)

Designate a set of paths through the program that must be exer- cised during testing.

- Statement Coverage - Branch Coverage - Cyclomatic coverage (“independent path testing”) - Data-flow Coverage

Mutation testing

Statement Coverage Require that every statement in the code be executed at least once during testing. Special programs ("software tools”) will monitor this requirement for you.

tcov in Unix for C, Pascal

commercial tools available for C++

12

(^1311)

10

9

6 7

4

2

8

1

5

3

1,2,3,5,6,11, 2,3,5,7,8, 10,11,2,3, 5,7,9,10,11, 2,12, 1,2,3,4,12, 39

Data-Flow Coverage Attempts to test significant combinations of branches.

Any stmt i where a variable X may be assigned a new value is

called a definition of X at i: def(X,i)

Any stmt i where a variable X may be used/retrieved is called a

reference or use of X at i: ref(X,i)

40

A path from stmt i to stmt j is def-clear with respect to X if

it contains no definitions of X except possibly at the beginning (i) and end (j)

41

The all-defs criterion requires that each definition def(X,i) be tested some def-clear path to some reference ref(X,j).

1: cin >> x >> y; d(x,1) d(y,1) 2: while (x > y) r(x,2), r(y,2) 3: { 4: if (x > 0) r(x,4) 5: cout << x; r(x,5) 6: x = f(x, y); r(x,6), r(y,6), d(x,6) 7: } 8: cout << x; r(x,8)

What kinds of tests are required for all-defs coverage? 42

The all-uses criterion requires that each pair (def(X,i), ref(X,j)) be tested using some def-clear path from i to j.

1: cin >> x >> y; d(x,1) d(y,1) 2: while (x > y) r(x,2), r(y,2) 3: { 4: if (x > 0) r(x,4) 5: cout << x; r(x,5) 6: x = f(x, y); r(x,6), r(y,6), d(x,6) 7: } 8: cout << x; r(x,8)

What kinds of tests are required for all-uses coverage? 43

Mutation Testing

Given a program 9 ,

Form a set of mutant programs that differ from 9 by some sin-

gle change

These changes (called mutation operators ) include:

- exchanging one variable name by another - altering a numeric constant by some small amount - exchanging one arithmetic operator by another - exchanging one relational operator by another - deleting an entire statement - replacing an entire statement by an abort() call

44

Mutation Testing (cont.)

Run 9 and each mutant 9 : on a previously chosen set of tests

Compare the output of each 9  to that of 9

– If the outputs differ on any test, 9  is killed and removed

from the set of mutant programs

– If the outputs are the same on all tests, 9 : is still considered

alive.

45

Mutation Testing (cont.) A set of test data is considered inadequate if it cannot distinguish

between the program as written ( 9 ) and programs that differ from it

by only a simple change.

So if any mutants are still alive after running a set of tests, we

augment the tests until we can kill all the mutants.

46

Mutation Testing Problems

Even simple programs yield tens of thousands of mutants. Exe-

cuting these is time-consuming.

- But most are killed on first few tests - And the process is automated

Some mutants are actually equivalent to the original program:

X = Y; X = Y;

if (X > 0) then if ( Y > 0) then .. .

- Identifying these can be difficult (and cannot be auto- mated)

47

1.2.3 Reliability Modeling with Directed Tests

Most literature on reliability models assumes that it can only be done with representative testing, because

Directed tests’ time-to-failure is unrelated to operational time-

to-failure

Directed tests may find faults “out of order”

Order Statistic Model Zeil & Mitchell (1996) presented a model for reliability growth under either representative or directed testing. Assumptions:

Software contains  faults, whose failure rates are described by

a distribution ;.

Faults manifest independently

The test process is biased towards finding faults with higher fail-

ure rates.

49

Measurement Process

Fault failure rates are measured when the fault has been identi-

fied and corrected.

Fault failure rate data is then sorted by failure rate.

The sorted data is fitted to an order statistic distribution.

- Order statistics is the study of the probability of selecting certain values when the selection process is biased.

50

Fitting Example

1e-

1e-

1

0 5 10 15 20 25 30 35

Failure Rate

Failure Number

LSq Fit - Sequence 2 Representative Directed OS JM ML