Professional Documents
Culture Documents
ST - Mod3 - Chapter 9 - PathTesting - Part1
ST - Mod3 - Chapter 9 - PathTesting - Part1
STRUCTURAL TESTING
2
Structural Testing
Also known as glass box ,white box , structural, clear box and open box testing.
A software testing technique whereby explicit knowledge of the internal
workings of the item being tested are used to select the test data.
Unlike black box testing that is using the program specification to examine
outputs.
white box testing is based on specific knowledge of the source code to define
the test cases and to examine outputs.
Read(ScoreFile, Score); 5
}
/* Compute the mean and print the result */
6 if (NumberOfScores > 0) {
Mean = SumOfScores / NumberOfScores;
printf(“ The mean score is %f\n”, Mean); 7
} else
printf (“No scores found in file\n”); 8
} 6
Constructing the Logic Flow Diagram
Start
F
2
T
3
T
4 F
6
T F
7 8
Exit
7
1 Program triangle2 `Structured programming version of simpler
specification
`
2 Dim a,b,c As Integer
3 Dim IsATriangle As Boolean
`
`Step1: Get Input
4 Output(“Enter the 3 integers which are sides of a triangle “)
5 Input(a,b,c)
6 Output(“Side A is “,a)
7 Output(“Side B is”,b)
8 Output(“Side C is”c)
`
`Step2:Is A Triangle?
9 If(a<b+c) AND (b<a+c) AND (c<a+b)
10 Then IsATriangle=True
11 Else IsATriangle=False
12 EndIf
`
8
`Step3:Determine Triangle Type
13 If IsATriangle
14 Then If(a=b) AND (b=c)
15 Then Output (“Equilateral”)
16 Else If( a!=b) AND (a!=c) AND (b!=c)
17 Then Output (“Scalene”)
18 Else Output (“ Isoceles”)
19 EndIf
20 EndIf
21 Else Output(“Not a Triangle”)
22 EndIf
`
23 Endtriangle2
9
10
11
Program Graph - Use
• The importance of program graph is that program executions
correspond to paths from the source to sink nodes.
12
13
DD-Paths
• The best known form of structural testing is based on a
construct known as a decision-to-decision path.
• The name refers to a sequence of statements that, begins
with the “outway” of a decision statement and ends with the
“inway” of the next decision statement.
• A DD-Path is a chain obtained from a program graph,
where a chain is a path in which the initial and terminal
nodes are distinct, and every interior node has indegree = 1,
and outdegree = 1.
• We show in the next slide on selecting the nodes from a
program graph to form a DD-Path chain. DD-Paths are used
to create DD-Path Graphs. 14
Notice that the initial node is 2-connected to every other node in
the chain, and no instances of 1- or 3-connected nodes occur, as
shown above.
The length (number of edges) of the chain is 6.
15
DD-Path Definition
• More formally a DD-Path is a chain obtained from a
program graph such that:
4 first 1
5-8 A 5
9 B 3
10 C 4
11 D 4
12 E 3
13 F 3
14 H 3
15 I 4
16 J 3 17
DD-Path Formation - Example
Program Graph Nodes DD-Path Name Case #
17 K 4
18 L 4
19 M 3
20 N 3
21 G 4
22 O 3
23 Last 2
18
•
DD-Path
Definition: DD-Path Graph
Graph
• Given a program written in an imperative language, its DD-Path graph
is a labeled directed graph, in which nodes are DD-Paths of its
program graph, and edges represent control flow between
successor DD-Paths.
19
Program Graph to DD-Path Graph
4 5 6 7 8
10 11
12
13
14
21
15 16
17 18
20
22
19
23
20
Topological Pathing
1. first – A – B – C – E – F – G – O – last
2. first – A – B – D – E – F – G – O – last
3. first – A – B – C – E – F – H – I – N – O – last
4. first – A – B – D – E – F – H – I – N – O – last
5. first – A – B – C – E – F – H – J – K – M – N – O – last
6. first – A – B – D – E – F – H – J – K – M – N – O – last
7. first – A – B – C – E – F – H – J – L – M – N – O – last
8. first – A – B – D – E – F – H – J – L – M – N – O – last
21
Feasible Paths
• If we assume that the logic of the program dictates that “if node C is
traversed, then we must traverse node H,(if istriangle=true then
if(a==b)||(b==c) and if node D is traversed, then we must traverse Node
G” if (istriangle=false) then output(“not a triangle”)
– These constraints will eliminate Paths 1, 4, 6 and 8
– Infeasible paths
1. first – A – B – C – E – F – G – O – last
4. first – A – B – D – E – F – H – I – N – O – last
6. first – A – B – D – E – F – H – J – K – M – N – O – last
8. first – A – B – D – E – F – H – J – L – M – N – O – last
• We are left to consider four feasible paths:
Feasible Paths:
2. first – A – B – D – E – F – G – O – last
3. first – A – B – C – E – F – H – I – N – O – last
5. first – A – B – C – E – F – H – J – K – M – N – O – last
7. first – A – B – C – E – F – H – J – L – M – N – O – last
22