Loading in 2 Seconds...
Loading in 2 Seconds...
Software Testing & Quality Assurance Lecture 10 Created by: Paulo Alencar Modified by: Frank Xu. Overview. Structural Testing Introduction – General Concepts Flow Graph Testing DDPaths Test Coverage Metrics Basis Path Testing Guidelines and Observations Data Flow Testing Hybrid Methods
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
G) = 3
1
Basis set:
x = z+5
1, 2, 3, 4, 6, 7
z = 4*3

y
1, 2, 3, 4, 5, 4, 6, 7
1, 2, 6, 7
x > z
2
t
Flow Graphs – Use in determining
Paths for Testing  Revisited
x = z+5
6
z = 4*3

y
f
R1
R2
if(x > z) goto A;
for( u=0; u < x; u++) {
3
z = z+1;
y = z+k
};
5
t
f
u = 0
A: y = z + k
z = z+1
R3
7
u++
4
u < x
Example of a simple control flowgraph.
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
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
A
A
E
B
C
G
F
D
I
H
L
K
J
last
[Jorgensen: Software Testing A Craftsman’s Approach]
1. program triangle (input, output);
2. VAR a,b,c: integer;
3. IsATriangle: boolean;
4. BEGIN
5. writeln(“Enter integers: “);
6. readln(a,b,c);
7. Writeln(“Side A is: “, a, “Side B is: “, b, “Side C is: “, c);
8. IF(a <b+c) AND (b < a+c) AND (c<a+b) THEN
9. IsATriangle = True;
10. ELSE IsATriangle = False;
11. IF IsATriangle)
12. THEN
13. BEGIN
14. IF (a=b) XOR (a=c) XOR (b=c) AND NOT((a=b) AND (a=c)
15. THEN writeln(“Equilateral”);
16. IF (a=b) AND (b=c)
17. THEN writeln(“Equilateral”);
18. IF(a <> b) AND (a <> c) AND (a<>c)
19. THEN writeln(“Scalene”);
20. END
21. ELSE Writeln(“Not a Triangle”);
22. END
P1: ABDEGIJKLast
P2: ACDEGIJKLast
P3: ABDLLast
P4: ABDEFGIJKLast
P5: ABDEFGHIJKLast
P6: ABDEFGHIKLast
A
A
E
B
C
G
F
D
I
H
L
K
J
last
[Jorgensen: Software Testing A Craftsman’s Approach]
1. program triangle (input, output);
2. VAR a,b,c: integer;
3. IsATriangle: boolean;
4. BEGIN
A5. writeln(“Enter integers: “);
A6. readln(a,b,c);
A7. Writeln(“Side A is: “, a, “Side B is: “, b, “Side C is: “, c);
A8. IF(a < b+c) AND (b < a+c) AND (c < a+b) THEN
B9. IsATriangle = True;
C10. ELSE IsATriangle = False;
D11. IF IsATriangle)
D12. THEN
E13. BEGIN
E14. IF (a=b) XOR (a=c) XOR (b=c) AND NOT((a=b) AND (a=c)
F15. THEN writeln(“Equilateral”);
G16. IF (a=b) AND (b=c)
H17. THEN writeln(“Equilateral”);
I18. IF(a <> b) AND (a <> c) AND (a<>c)
J19. THEN writeln(“Scalene”);
K20. END
L21. ELSE Writeln(“Not a Triangle”);
22. END
Node B is traversed D, E are traversed
Node C is traversed D, L are traversed
Node E is traversed F, H, J are traversed
Node F is traversed H, J are traversed
Node H is traversed F, J are traversed
Node J is traversed F, I are traversed
Logically feasible paths:
P1: ACDLLast
P2: ABDEFGIKLast
P3: ABDEGHIKLast
P4: ABDEGIJKLast
s1
s1
s1
s1
s1
s1
s2
s3
s4
s2
s3
s2
s2
s2
s2
s3
s5
s4
s3
Sequence ifthenelse case ifthen looppretest loopposttest
s1
s1
s1
s1
s0
s0
s2
s2
s2
s2
s0
s1
s3
s3
s3
s3
Branching into loop Branching out of loop Branching into decision Branching out of decision
1
2
Statement Coverage C0:
SCPath1: 123(F)10(F)1113
SCPath2: 123(T)4(T)56(T)
7(T)893(F)10(T)1213
F
T
3
F
10
4
F
T
T
5
12
11
Branch or Decision Coverage C1:
BCPath1: 123(F)10(F)1113
BCPath2: 123(T)4(T)56(T)
7(T)893(F)10(T)1213
BCPath3: 123(T)4(F)10(F)1113
BCPath4: 123(T)4(T)56(F)93(F)
10(F)1113
BCPath5: 123(T)4(T)56(T)7(F)9
3(F)10(F)1113
6
F
T
13
7
F
T
8
9
Setting A = True, B = False, then A = False and B = True satisfies Condition Coverage, but statement C will never be executed
A = True, B = True
A = True, B = False
A = False, B = True
A = False, B = False
3 test cases: A = True, B = False (A dominates)
A = False, B = True (B dominates)
A = False, B = False (false outcome)
A: T F F
B: F T F
A: F T T
B: T F T
A: T T F
B: T F T
P
T
Guidelines and ObservationsP
T
Guidelines and Observations2
6
5
1
4
3
7