Data Flow Testing
Data Flow Testing
DD Path graph is given in Fig. 20 (b)
Indeenden
e
(i) ABFGNPQR
(ii) ABFGNOQR
(iii) ABCEGNPQR
(iv) ABCDEGNOQR
(v) ABFGHIMQR
(vi) ABFGHJKMQR
(vii)ABFGHJMQR
O
|
Ô
Ôex
O O
|
÷here will be five independent paths for the flow graph illustrated in Fig. 21.
|
|evee
e
ex
e
ede
1. V(G) 1
O
|
Õ `!
= 13-13+2*3
=6
Õ ` Õ `G
Õ `
|
O
|
|
n
Cyclomatic complexity can be calculated by any of the three methods.
1. V(G) =± + 2P
= 13 ± 10 + 2 = 5
2. V(G) =ʌ+1
=4+1=5
ëxe
Consider the previous date program with DD path graph given in Fig. 17.
Find cyclomatic complexity.
|
| n
ëxe
Consider the quadratic equation problem given in example 8.13 with its DD
Path graph. Find the cyclomatic complexity:
|
| n
Number of nodes ( ) = 19
Number of edges () = 24
(i) V(G) = ± + 2P = 24 ± 19 + 2 = 7
(ii) V(G) = ʌ + 1 = 6 + 1 = 7
(iii) V(G) = Number of regions = 7
ëxe
| n
÷he square matrix represent that there are two path and from node 1 to
node 2.
|
ëxe
Consider the flow graph shown in the Fig. 26 and draw the graph & connection
matrices. Find out cyclomatic complexity and two / three link paths from a node to
any other node.
O O
|
|
n
÷he graph & connection matrices are given below :
÷o find two link paths, we have to generate a square of graph matrix [A] and for three
link paths, a cube of matrix [A] is required.
|
|
Oe
n
Data flow testing is another from of structural testing. It has nothing to do with data
flow diagrams.
e n n
÷he definitions refer to a program P that has a program graph G(P) and a set of
program variables V. ÷he G(P) has a single entry node and a single exit node. ÷he
set of all paths in P is PA÷HS(P)
e n n de Node n ' G(P) is a defining node of the variable î ' V,
written as DEF (î, ), if the value of the variable î is defined at the statement
fragment corresponding to node .
e de Node n ' G(P) is a usage node of the variable î ' V, written as
USE (î, ), if the value of the variable î is used at statement fragment
corresponding to node . A usage node USE (î, n) is a predicate use (denote
as p) if statement n is a predicate statement otherwise USE (î, n) is a
computation use (denoted as ).
|
e n
n e A definition use path with respect to a variable v (denoted
du-path) is a path in PA÷HS(P) such that, for some î ' V, there are define and
usage nodes DEF(v, m) and USE(v, n) such that m and n are initial and final
nodes of the path.
v
e n
n e A definition clear path with respect to a variable v (denoted
dc-path) is a definition use path in PA÷HS(P) with initial and final nodes DEF (î,
m) and USE (î, n), such that no other node in the path is a defining node of î.
÷he du-paths and dc-paths describe the flow of data across source statements from
points at which the values are defined to points at which the values are used. ÷he
du-paths that are not definition clear are potential trouble spots.
|
Hence, our objective is to find all du-paths and then identity those du-paths which are
not dc-paths. ÷he steps are given in Fig. 27. We may like to generate specific test
cases for du-paths that are not dc-paths.
Ôn
|
|
e I ÷he program flow graph is given in Fig. 19 (a). ÷he variables used in the
program are a,b,c,d, validinput, D.
|
e II DD Path graph is given in Fig. 19(b). ÷he cyclomatic complexity of this graph
is 7 indicating there are seven independent paths.
è e
e ned
nde ed
nde
a 6 11,13,18,20,24,27,28
b 8 11,18,20,24,28
c 10 11,18
d 18 19,22,23,27
D 23, 27 24,28
Validinput 3, 12, 14 17,31
|
|
e Iè ÷he du-paths are identified and are named by their beginning and ending
nodes using Fig. 19 (a).
è e
e nn n endnde
e n
ne!
6, 11 Yes
a
6, 13 Yes
6, 18 Yes
6, 20 Yes
6, 24 Yes
6, 27 Yes
6, 28 Yes
8, 11 Yes
b 8, 18 Yes
8, 20 Yes
8, 24 Yes
8, 28 Yes
|
è e
e nn n endnde
e n
ne!
10, 11 Yes
c
10, 18 Yes
d 18, 19 Yes
18, 22 Yes
18, 23 Yes
18, 27 Yes
D 23, 24 Yes
23, 28 Path not possible
27, 24 Path not possible
27, 28 Yes
3, 17 no
validinput
3, 31 no
12, 17 no
12, 31 no
14, 17 yes
14, 31 yes
|
ëxe
Consider the program given in Fig. 20 for the classification of a triangle. Its
input is a triple of positive integers (say a,b,c) from the interval [1,100]. ÷he
output may be:
[Scalene, Isosceles, Equilateral, Not a triangle, Invalid inputs].
Find all du-paths and identify those du-paths that are definition clear.
|
|
n
|
e I ÷he program flow graph is given in Fig. 20 (a). ÷he variables used in
the program are a,b,c, valid input.
è e
e ned
nde ed
nde
a 6 10, 11, 19, 22
b 7 10, 11, 19, 22
5, 10 Yes
a
5, 11 Yes
5, 19 Yes
5, 22 Yes
7, 10 Yes
b 7, 11 Yes
7, 19 Yes
7, 22 Yes
|
è e
e nn n endnde
e n
ne!
9, 10 Yes
c
9, 11 Yes
9, 19 Yes
9, 22 Yes
3, 18 no
valid input
3, 29 no
12, 18 no
12, 29 no
16, 18 Yes
16, 29 Yes
Hence total du-paths are 18 out of which four paths are not definition clear
|
ne
n
Mutation testing is a fault based technique that is similar to fault seeding, except that
mutations to program statements are made in order to determine properties about
test cases. it is basically a fault simulation technique.
Multiple copies of a program are made, and each copy is altered; this altered copy is
called a mutant. Mutants are executed with test data to determine whether the test
data are capable of detecting the change between the original program and the
mutated program.
A mutant that is detected by a test case is termed ³killed´ and the goal of mutation
procedure is to find a set of test cases that are able to kill groups of mutant
programs.