Flow Graph and Path Testing
Flow Graph and Path Testing
X
Decision:
Yes Do Function1()
Input
If A = B
No Do Function2()
Junctions:
interrupt
1 2
Case statement:
Case n
Control Flow Graph Vs Flow Charts
Inside details of a process block are not Every part of the process block are
shown drawn
INPUT X, Y
Z := X + Y
V := X - Y
IF Z >= 0 GOTO SAM
JOE: Z := Z + V
SAM: Z := Z - V
FOR N = 0 TO V NO
Z := Z - 1 INPUT X, Y Z := X + Y V := X - Y Z >= 0 ? JOE
NEXT N
END
LOOP SAM Z := Z + V
Z := Z - 1 N := 0 Z := Z - V
NO
N=V? N := N+1
YES
END One to One Flow Chart
Notational evolution - Creation of Control Flow Graph from a program
INPUT X, Y
Z := X + Y
V := X - Y
IF Z >= 0 GOTO SAM
JOE: Z := Z + V
SAM: Z := Z - V
FOR N = 0 TO V NO
Z := Z - 1 P1 Z >= 0 ? JOE
NEXT N
END
LOOP SAM P2
P4 P3
NO
N=V? P5
YES
END
Simplified Flow Graph
Flow graph-program correspondence
Flow graph is a pictorial representation of a program and not the
program itself
The translation from a flow graph element to a statement and
vice versa is not always unique.
NO NO
NO
Fig: Alternative Flow graphs for same logic (Statement "IF (A=0) AND (B=1) THEN . . .").
Flow graph and flow chart generation
1.Hand-drawn by programmer.
2.Automatically produced by a flowcharting program
based on a mechanical analysis of the source code.
3.Semi automatically produced by a flow charting program
based in part on structural analysis of the source code
Basic concepts- nodes, links and paths
path testing
statement testing
branch testing
Picking appropriate tests paths
Observe the control flow graph that drawn to represent the program structure.
List all these paths that are being identified so that C1+C2 criteria has been
fulfilled.
Form the table from graphical representation with labelled links.
Types of loops:
single loop
nested loops
concatenated loops
Predicates, Path Predicates and Achievable paths
Predicate:
Its a logical function evaluated at decision point.
Predicates, Path Predicates and Achievable paths
Path predicate:
A predicate associated with a path is called a predicate
path.
Predicate interpretation:
The act of symbolic substitution of operations along
the path in order to express the predicate solely in terms of
the input vector is called interpretation.
Predicates, Path Predicates and Achievable paths