Data Flow Testing
Data Flow Testing
• Definition
• Node n ∈ G(P) is a defining node of the variable v ∈ V, written as
DEF(v, n), if and only if the value of variable v is defined as the
statement fragment corresponding to node n.
• Input statements, assignment statements, loop control statements, and
procedure calls are all examples of statements that are defining nodes.
Definition
• Node n ∈ G(P) is a usage node of the variable v ∈ V, written as
USE(v, n), if and only if the value of the variable v is used as the
statement fragment corresponding to node n.
• Output statements, assignment statements, conditional statements,
loop control statements, and procedure calls are all examples of
statements that are usage nodes.
Definition
• A usage node USE(v, n) is a predicate use (denoted as P-use) if and
only if the statement n is a predicate statement; otherwise, USE(v, n) is
a computation use (denoted C-use).
• The nodes corresponding to predicate uses always have an outdegree ≥
2, and nodes corresponding to computation uses always have an
outdegree ≤ 1.
• Definition
• A definition/use path with respect to a variable v (denoted du-path) is
a path in PATHS(P) such that, for some v ∈ V, there are define and
usage nodes DEF(v, m) and USE(v, n) such that m and n are the initial
and final nodes of the path.
Definition
• A definition-clear path with respect to a variable v (denoted dc-path)
is a definition/use path in PATHS(P) with initial and final nodes
DEF(v, m) and USE(v, n) such that no other node in the path is a
defining node of v.
Examples: Commission Problem
• du_paths for stock:DEF(Stocks,15) and USE(stock,17)
path<15,17>
27
Slice-Based Testing Definitions
Given a program P, and a set V of variables in P, the slice on the variable set V at statement
fragment n, written S(V,n), is of all statement fragments in P prior to node n that contribute to
the values of variables in V at node n.
Listing element of a slice S(V,n) will be cumbersome bcz the elements are program statement.
Given a program P, and a program graph G(P) in which statements and statement fragments
are numbered, and a set V of variables in P, the slice on the variable set V at statement
fragment n, written S(V,n), is the set node numbers of all statement fragments in P prior to n
that contribute to the values of variables in V at statement fragment n
The idea of slices is to separate a program into components that have some useful meaning.
The “prior to” in the dynamic sense,so a slice captures the
28
Slice-Based Testing Definitions
• The “contribute” part is more complex. In a sense, data declaration statements have an
effect onthe value of a variable.The notion of contribution is partially clarified by
predicate(P-use) and computation(C-usage) .
Five forms of usage nodes
P-use (used in a predicate (decision))
C-use (used in computation)
O-use (used for output, e.g. writeln())
L-use (used for location, e.g. pointers)
I-use (iteration, e.g. internal counters)
Two forms of definition nodes
I-def (defined by input, e.g. readln())
A-def (defined by assignment)
For now, we presume that the slice S(V,n) is a slice on one variable, that is, the set V
consists of a single variable, v
29
Slice-Based Testing Definitions
If statement fragment n (in S(V,n)) is a defining node for v, then n is
included in the slice
P-uses and C-uses of other variables are included to the extent that
their execution affects the value of the variable v
30
Example
• Slice on the locks:P-use at node 14,C-use at node 16, the I-
dedefs at node 13 &19
S1:S(locks,13)={13},
s2:S(locks,14)={13,14,19,20},
S3:S(locks,16)={13,14,19,20}, S4:S(locks 19)={19}
• Slice on sales
S24:S(sales,27)={7,8,9,10,11,12,13,14,15,16,17,18,19,20,24,25,26,27}
The above slice is same for node 28,29,33 34,37 and 39.
Slice on commission
S32:S(Commission,32)={31,32}
S34:S(Commission, 36)={36}
S36:S(Commission,39)={7,8,9,10,11,12,13,14,15,16,17,18 ,19,20,24,25,26,27,29,34,38,39}
S37:S(Commission,41)={7,8,9,10,11,12,13,14
15,16,17,18,19,20,24,25,26,27,29,39,31,32,33,34,35 36,37,38,39}
Thank You