Docsity

Software Test Data Generation: Study on Adequacy Criteria and Evolutionary Algorithms, Study notes of Computer Science

Partial preview of the text

Download Software Test Data Generation: Study on Adequacy Criteria and Evolutionary Algorithms and more Study notes Computer Science in PDF only on Docsity!

Software Test Data GenerationUsing Evolution

Gursaran Reader Dept. of Mathematics Dayalbagh Educational Institute

Gursaran

Dayalbagh Educational Institute

Outline „

Test Adequacy Criterion

„

Test Data Generation Problem

„

Evolutionary Algorithms

„

Evolutionary Algorithms for Test Data Generation

„

Testing Object-Oriented Software

„

Test Data Generation using UML and GeneticAlgorithms

Gursaran

Dayalbagh Educational Institute

Test Data Adequacy Criterion „

Testing can only detect the presence of faultsbut not their absence.

„

Central questions in software testing ‰

What is the test criterion?

‰

What constitutes an adequate test?

Gursaran

Dayalbagh Educational Institute

Test Data Adequacy Criteria „

A predicate

„

Specifies testing requirements

„

Requirements on Test Data AdequacyCriteria ‰

Reliability

‰

Validity

„

Not practically applicable

Gursaran

Dayalbagh Educational Institute

Test Data Adequacy Criteria as Measurements A test data adequacy criterion is a function

C

C

:^

P x S x T ->

[0,1]

C

( p

,^

s

,^

t ) =

r

means that the adequacy of testing the program

p

by the test set

t

with respect to the specification

s

is of degree

r

according to the criterion

C

. The greater the real number

r

the more adequate the testing.

[Zhu et al., 1997]

Gursaran

Dayalbagh Educational Institute

Classification

Structural

Fault Based

Error Based

Program Based

Specification Based

[Zhu et al., 1997]

Gursaran

Dayalbagh Educational Institute

s

CFG Node s

int triType(int a, int b, int c) {

1

int type = PLAIN;

1

if (a > b)

2

swap(a, b);

3

if (a > c)

4

swap(a,c);

5

if (b > c)

6

swap(b, c);

7

if (a == b) {

8

if (b == c)

9

type = EQUILATERAL;

else

10

type = ISOSCELES; }

11

else if (b == c)

12

type = ISOSCELES;

13/

e return type;

}

Gursaran

Dayalbagh Educational Institute

Definitions „

An

input vector

I is a vector I = (x

1

, x

2

,... x

k

) of input

variables to a program.

„

The

domain of an input variable

x

, 1i^

i

k, is the set of all

values that x

i^

can take on.

„

The

domain of a program

is the cross product D = D

x

× D

x

×... × D

xk

where each D

xi

is the domain of the input variable

x

.i^

„

A

program input

x

is a single point in the k-dimensional input

space D,

x

D.

„

A

path

through a CFG is a sequence P =< n

1

, n

2

,... n

m

such that for i, 1

i < m, (n

, ni

i+

)^

E.

„

A path is

feasible

if there exists a program input x for which

the path is traversed during program execution.

Gursaran

Dayalbagh Educational Institute

Applicability „

Finite Applicability

  • Requirement that an adequacy criterion

can always be satisfied by a finite test set. ‰

Problems „

Infinite number of different paths

„

Infeasibility

„

Limit testing to feasible versions of adequacy criteria

„

Leads to the

undecidability

problem

‰

Whether a statement in a program is feasible or not isundecidable

‰

It is not possible to take an adequacy criterion anddetermine whether an input exists that satisfies it.

[Zhu et al., 1997]

Gursaran

Dayalbagh Educational Institute

Automated Test Data Generation: ACompromise „

The

undecidable

problem

„

Attempt under resource limitations ‰

If resources are exhausted, the attempt fails

„

What is the best that we can do within the allocatedresources?

Gursaran

Dayalbagh Educational Institute

Problem Restatement „

Reduce the problem of test data generation to a sequence ofsubgoals each of which can be solved using functionminimisation

„

Assume

simple

relational expressions involving arithmetic

expressions

E

1

E

2

E

2

  • E

1

< 0

or F < 0

[Korel, 1990]

Gursaran

Dayalbagh Educational Institute

Problem Restatement „

Branch predicates can be transformed into anequivalent predicate

F(x)

rel 0, rel

∈

{ <, <=, = },

x

∈

D,

where

true

is

Predicate

Branch

when

or

with

(or

negative

false

is

Predicate

Branch

en

wh

with

(or

positive

x

F

[Korel, 1990]

Gursaran

Dayalbagh Educational Institute

Problem Restatement „

The function F is

„

Problem of test data generation isreduced to function minimisation: ‰

Find an input

x

that minimizes

F(x)

taken is

branch

TRUE

when ,

negative

or 0

taken is

branch

FALSE

when ,

(^

v p

x

F

F <= 0

Gursaran

Dayalbagh Educational Institute

Problem Restatement

7

F < 0

3 4 6

9

5 8

1

2

„

Constraints?

„

The Branch Conditionmay not be reached forcertain inputs ‰

Treat the problem ofreaching the branchcondition as a subgoalbefore minimizing

F(x)