0% found this document useful (0 votes)
15 views21 pages

Data Flow Testing

Data flow testing is a structural testing method focusing on how variables are defined and used within a program. It identifies potential issues such as variables that are defined but not used or used without being defined. The document also provides examples of data flow testing through triangle classification and quadratic equation programs, detailing the paths and nodes involved in the testing process.

Uploaded by

harishs24082003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views21 pages

Data Flow Testing

Data flow testing is a structural testing method focusing on how variables are defined and used within a program. It identifies potential issues such as variables that are defined but not used or used without being defined. The document also provides examples of data flow testing through triangle classification and quadratic equation programs, detailing the paths and nodes involved in the testing process.

Uploaded by

harishs24082003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Data Flow

Testing
Software
Testing
Data Flow Testing
Data flow testing is another from of structural testing. It has nothing to
do with data flow diagrams.

i. Statements where variables receive values.

ii. Statements where these values are used or referenced.

As we know, variables are defined and referenced throughout the


program. We
may have few define/ reference anomalies:

iii. A variable is defined but not used/ referenced.

iv. A variable is used but never defined.

v. A variable is defined twice before it is used.


Software Testing

Definitions
The definitions refer to a program P that has a program graph G(P) and a set of
program variables V. The G(P) has a single entry node and a single exit node. The
set of all paths in P is PATHS(P)

(i) Defining Node: Node n G(P) is a defining node of the variable v V,


written as DEF (v, n), if the value of the variable v is defined at the statement
fragment corresponding to node n.

(ii) Usage Node: Node n G(P) is a usage node of the variable v V, written as
USE (v, n), if the value of the variable v is used at statement fragment
corresponding to node n. A usage node USE (v, n) is a predicate use (denote
as p) if statement n is a predicate statement otherwise USE (v, n) is a
computation use (denoted as c).
Software Testing

(iii) Definition use: 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 initial and final
nodes of the path.

(iv) Definition clear : 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.

The 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. The
du-paths that are not definition clear are potential trouble spots.

157
Software
Testing

Consider a program for the classification of a triangle. Its input is a


triple of positive integers (say a,b,c) from the interval [1,100]. The
output may be [Scalene, Isosceles, Equilateral, Not a triangle].
Draw the flow graph & DD Path graph. Also find the independent paths
from the DD Path graph.
Software
Testing
Software
Testing

Code of triangle classification problem


Software
Testing
DD Path graph is given
below:

Independent paths are:


(i) ABFGNPQR
(ii)ABFGNOQR
(iii)ABCEGNPQR
(iv)ABCDEGNOQR
(v)ABFGHIMQR
(vi)ABFGHJKMQR
(vii)ABFGHJLMQR

DD Path graph
Software
Testing

Consider the program for the classification of a triangle. Its


input is a triple of positive integers (say a,b,c) from the interval
[1,100]. The
output may be:
[Scalene, Isosceles, Equilateral, Not a triangle, Invalid inputs].
Find all du-paths and identify those du-paths that are definition
clear.
Software
Testing
Solution

Step I: Consider the flow graph. The variables


used in
the program are a,b,c, valid input.

Step II: DD Path graph The cyclomatic


complexity of
this graph is 7 and thus, there are 7
independent paths.
Variable Defined at node Used at node
Step III: Define/useanodes for all variables
5
are given
10, 11, 19, 22
below:
b 7 10, 11, 19, 22

c 9 10, 11, 19, 22

valid input 3, 12, 16 18, 29


Software
Testing
Step IV: The du-paths are identified and are named by their beginning
and ending nodes using Fig

Variable Path (beginning, end) nodes Definition clear ?

5, Ye
a
10 s
5, Ye
11 s
5, Ye
19 s
7, Ye
5,
b 10 sYe
22 s
7, Ye
11 s
7, Ye
19 s
7, Ye
22 s
Software
Testing
Variable Path (beginning, end) nodes Definition clear ?

9, 10 Ye
c
9, 11 s
9, 19 Ye
9, 22 s
Ye
valid
3, 18 sNo
input 3, 29 No
Ye
12, sNo
18 No
12, Yes
29 Yes
16,
18
Hence total du-paths are 1816,
out of which four paths are not
definition clear 29
Software
Testing
Consider the program of the determination of the nature of roots of a
quadratic equation. Its input is a triple of positive integers (say a,b,c)
and values for each of these may be from interval [0,100]. The
program is given below. The output may have one of the option given
below:
(i) Not a quadratic program
(ii)real roots
(iii)imaginary roots
(iv)equal roots
(v)invalid inputs
Find all du-paths and identify those du-paths that are definition clear.
Software
Testing
Solution

Step I: The program flow graph is given The variables


used in the program are a,b,c,d, validinput, D.
Step II: DD Path graph is given. The cyclomatic complexity
of this graph
is 7 indicating there are seven independent paths.

Step III: Define/use nodes for all variables are given below:
Variable Defined at node Used at node

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
Validinp 3, 12, 17,3
ut 14 1
Software
Testing
Step IV: The du-paths are identified and are named by their beginning
and ending nodes using Fig
Variable Path (beginning, end) nodes Definition clear ?
6, 11 Ye
a
6, 13 s
6, 18 Ye
6, 20 s
6, 24 Ye
6, 27 s
6, 28 Ye
s
8, 11
Ye
b 8, 18
s
8, 20
Ye
8, 24
s
8, 28
Ye
s
Ye
s
Ye
Software
Testing
Variable Path (beginning, end) nodes Definition clear ?
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
27, Pathpossible
not
24 possible
27, Yes
3, 17
28
validinp
ut 3, 31 no
12, no
17 no
12, no
31
14, ye
17 s
14, ye

You might also like