Professional Documents
Culture Documents
Testing Lecture 09 - White Box Testing I
Testing Lecture 09 - White Box Testing I
Testing Lecture 09 - White Box Testing I
Lecture No. 09
Last Lecture Review
2 Software Testing
What Will You Learn Today?
3 Software Testing
.
4 Software Testing
White Box Testing
5 Software Testing
White Box Testing - Applicability
6 Software Testing
White Box Testing
7 Software Testing
i. Control Flow Testing
Coverage metrics
Measure of how complete the test cases are
Not the same as how good they are!
8 Software Testing
Control Flow Graphs
Sequence
if Case
While Until
10 Software Testing
Code Coverage (Test Coverage Metrics)
Levels of Coverage:
Statement/Line/Basic block/Segment
Coverage
Decision (Branch) Coverage
Condition Coverage
Multiple Condition Coverage
Decision/Condition Coverage
Loop Coverage
Path Coverage
11 Software Testing
Statement Coverage
Execute each statement at least once
Begin
if ( y >= 0)
then y = 0; yes
abs = y; no
end;
12 Software Testing
Statement Coverage
Execute each statement at least once
Begin
if ( y >= 0)
then y = 0; yes
abs = y; no
end;
test case-1(yes):
input: y = ?
expected result: ? Write test cases to execute every
actual result: ? statement!
13 Software Testing
Statement Coverage
Execute each statement at least once
Begin
if ( y >= 0)
then y = 0; yes
abs = y; no
end;
100% statement coverage!
14 Software Testing
What is wrong with line coverage
15 Software Testing
Decision (Branch) Coverage
Execute each edge in the CFG at least once
Begin
if ( y >= 0)
then y = 0;
abs = y;
end;
16 Software Testing
Decision (Branch) Coverage
Execute each edge in the CFG at least once
Begin
if ( y >= 0)
then y = 0;
abs = y;
end;
17 Software Testing
Decision (Branch) Coverage
Execute each edge in the CFG at least once
Begin
if ( y >= 0)
then y = 0;
abs = y;
end;
18 Software Testing
Condition Coverage
Each condition in each decision must be both true and false
Begin
if ( x < 10 && y > 20) {
z = foo (x, y);
else
z =fie (x, y);
}
end;
19 Software Testing
Condition Coverage
Each condition in each decision must be both true and false
Begin
if ( x < 10 && y > 20) {
z = foo (x, y);
else
z =fie (x, y);
}
end;
20 Software Testing
Condition Coverage
Each condition in each decision must be both true and false
Begin
if ( x < 10 && y > 20) {
z = foo (x, y);
else
z =fie (x, y);
}
end;
21 Software Testing
Multiple Condition Coverage
All combinations of conditions must be executed in each decision
Begin
if ( x < 10 && y > 20) {
z = foo (x, y);
else
z =fie (x, y);
}
end;
x<? y>?
--------------------------------------------
test-case-1: T T
test-case:2 T F
test-case-3: F T
test-case-4: F F
22 Software Testing
Multiple Condition Coverage
All combinations of conditions must be executed in each decision
Begin
if ( x < 10 && y > 20) {
z = foo (x, y);
else
z =fie (x, y);
}
end;
x < 10 y > 20
--------------------------------------------
test-case-1: T T
test-case:2 T F
test-case-3: F T
test-case-4: F F
23 Software Testing
Decision/Condition Coverage
Satisfy both condition and decision coverage
Begin
if ( x < 10 && y > 20) {
z = foo (x, y);
else
z =fie (x, y);
}
end;
test case-1(T, T, yes): test case-2(F, F, No):
input: x = ?; y = ? input: x = ?; y = ?
expected result: ? expected result: ?
actual result: ? actual result: ?
24 Software Testing
Decision/Condition Coverage
Satisfy both condition and decision coverage
Begin
if ( x < 10 && y > 20) {
z = foo (x, y);
else
z =fie (x, y);
}
end;
test case-1(T, T, yes): test case-2(F, F, No):
input: x = -4; y = 30 input: x = 12; y = 12
expected result: ? expected result: ?
actual result: ? actual result: ?
25 Software Testing
Loop Coverage
26 Software Testing
Recap
27 Software Testing
Questions
28 Software Testing