You are on page 1of 18

Overview

Structural Testing
Introduction – General Concepts
Flow Graph Testing
Data Flow Testing
Definitions
Some Basic Data Flow Analysis Algorithms
Define/use Testing
Slice Based Testing
Guidelines and Observations
Hybrid Methods
Retrospective on Structural Testing

1
Data Flow testing
• Dataflow testing refers to forms of structura
l testing that focus on the points at which va
riables receive values and the points at whic
h these values are used.
• Most programs deliver functionality in term
s of data.
• Variables that represent data some how rece
ive values,and these values are used to com
pute values for other variables.
2
• Early dataflow analyzers often centered on
a set of faults that are now known as define/
reference anomalies:
• A variable that is defined but never used(ref
erenced).
• A variable that is used before it is defined.
• A variable that is defined twice before it is
used.

3
Data Flow Testing – Basic Idea
• Data-flow testing involves selecting entry/exit paths with t
he objective of covering certain data definition and use patt
erns, commonly known as data-flow criteria

• An outline of data-flow testing is as follows:


– Draw a data flow graph for the program
– Select data-flow testing criteria
– Identify paths in the data-flow graph to satisfy the selection criteria
(i.e. all-defs, all-uses, all-P-uses/some-C-uses etc.)
– Produce test cases for the selected paths

4
Some Definitions

1. Node n in the CFG of program P is a defining


node of the variable v V, written  as DEF(v,
n), iff the value of the variable v is defined a
t the statement fragment corresponding to
node n.
Eg: Input statement,assignment,loop contro
l,and procedure calls.

5
2.Node n in the CFG of program P is
a usage node of the variable v  V,
written as USE(v, n), iff the value
of the variable v is used at the
statement fragment
corresponding to node n.

6
Some Definitions (2)
• A usage node USE(v, n), is a predicate use (denote
d as P-use) iff the statement n is a predicate statem
ent, otherwise USE(v, n) is a computation use or C
-use

• The nodes corresponding to predicate uses have al


ways an outdegree ≥ 2, and nodes corresponding t
o computation uses always have outdegree ≤ 1

7
Some Definitions (3)
• A definition-use (sub)path with respect to a variable v (de
noted as du-path) is a (sub)path in PATHS(P), where PAT
HS(P) is the set of all possible paths in the CFG of progra
m P, such that, for some v in V, there are define and usage
nodes DEF(v, m) and USE(v, n) such that m, and n are the i
nitial and final nodes in the path respectively.

• A definition-clear (sub)path with respect to a variable v (d


enoted as dc-path) is a definition-use path in PATHS(P) wi
th initial nodes DEF(v, m) and USE(v, n) such that there no
other node in the path is a defining node for v

8
9
10
11
12
• Du-paths for Stocks
• First, let us look at a simple path: the du-path for t
he variable stocks. We have DEF(stocks, 15) and
• USE(stocks, 17), so the path <15, 17> is a du-path
with respect to stocks. No other defining nodes are
used for stocks; therefore, this path is also definiti
on clear.

13
• Du-paths for Locks
• Two defining and two usage nodes make the locks variable
more interesting: we have DEF(locks,
• 13), DEF(locks, 19), USE(locks, 14), and USE(locks, 16).
These yield four du-paths; they are
• shown in Figure 9.3.
• p1 = <13, 14>
• p2 = <13, 14, 15, 16>
• p3 = <19, 20, 14>
• p4 = <19, 20, 14, 15, 16>
14
DU-Path Test Coverage Criteria
• The basic idea is to use def-use information as defi
ned in the previous slides and specific criteria in o
rder to obtain specific paths in the CFG graph. The
se paths will then help us define specific test cases

• Let T be a set of feasible complete paths in the pr


ogram’s P CFG, and V be the set of all variables in
the program P

15
DU-Path Coverage Criteria (1)
• The set T satisfies the All-Defs criterion for a program P iff
for every variable v in V, T contains definition clear (sub)p
aths from every defining node of v to a use of v. Note: Rea
ching definitions set

• The set T satisfies the All-Uses criterion for the program P


iff for every variable v in V, T contains definition-clear (su
b)paths from every defining node of v to every use of v, an
d to the successor node of each USE(v, n)
Note: def-use chains set

• We can distinguish between an All-C-Uses, or an All-P-Us


16
es set
DU-Path Coverage Criteria (2)
• The set T satisfies the All-P-Uses/Some-C-Uses criterion for a program P iff f
or every variable v in V, T contains definition-clear (sub)paths from every defi
ning node of v to every p-use of v, and if a definition of v has no p-uses, there i
s a definition-clear path to at least one c-use

• The set T satisfies the All-C-Uses/Some-P-Uses criterion for a program P iff f


or every variable v in V, T contains definition-clear (sub)paths from every defi
ning node of v to every c-use of v, and if a definition of v has no c-uses, there i
s a definition-clear path to at least one p-use

• The set T satisfies the All-DU-Paths criterion for the program P iff for every v
ariable v in V, T contains definition-clear (sub)paths from every defining node
of v to every use of v, and to the successor node of each USE(v, n), and that th
ese paths are either single loop traversals or cycle free

17
18

You might also like