White Box
White Box
expected.
How do you test a system?
How do you test a system?
Verification is the
process of determining:
whether the output of one
phase of development
conforms to its previous phase.
whether a fully developed system
Validation
conforms to is
itsthe
SRSprocess of
document.
determining
Verification versus Validation
Aim of Verification:
phase containment of errors
Aim of validation:
final product is error free.
Verification versus Validation
Verification:
are we doing right?
Validation:
have we done right?
Design of Test Cases
Exhaustive testing of any
system is impractical:
input data domain is
extremely large.
Design an optimal test suite:
of reasonable size
to uncover as many errors
as
possible.
Design of Test Cases
If test cases are selected randomly:
many test cases do not contribute
to the significance of the test
suite,
do not detect errors not already
detected by other test cases in the
suite.
The number of test cases in a
randomly selected test suite:
not an indication of the effectiveness
of the testing.
Design of Test Cases
Consider an example:
If (x>y) max = x;
else max = x;
The code has a simple error:
test suite {(x=3,y=2);
(x=2,y=3)} can detect the error,
a larger test suite
{(x=3,y=2); (x=4,y=3);
(x=5,y=1)} does not detect
the error.
Design of Test Cases
turn.
Branch Coverage
Branch testing guarantees
statement coverage:
a stronger testing compared to
the statement coverage-based
testing.
Example
int f1(int x,int
y){
if (x>y)
1 whilethen
(x !=
2
y){
x=x-y;
5 }else y=y-x;
3
6 return x;
}
4
Example
Test cases for branch
coverage can be:
{(x=3,y=3),(x=3,y=2),
(x=4,y=3), (x=3,y=4)}
Condition Coverage
Test cases are designed such
that:
each component of a
composite conditional
expression
given both true and false
values.
Example
Consider the conditional
expression
((c1.and.c2).or.c3):
testing:
Branch testing
coverage testing.
Condition coverage
Consider a Boolean
expression having n
components:
for condition coverage, we
n
require 2 test cases. (n is no. of
condtions)
Path Coverage
Design test cases such that:
all linearly independent paths
in the program are executed
at least once.
Linearly independent
paths
Defined in terms of
control flow graph (CFG) of a
program.
Path coverage-based
testing
To understand the path
coverage-based testing:
we need to learn how to draw
describes:
the sequence in which
different
instructions of a program get
executed.
the way control flows through
the program.
How to draw Control flow
graph?
flow graph.
How to draw Control flow
graph?
1
Sequence: 2
1 a=5;
2
b=a*b-1;
How to draw Control flow
graph?
Selection:
1 if(a>b)
c=3
2
then ;
3
4 c=5
else ;
c=c*c;
How to draw Control flow
graph?
Iteration:
1 while(a>b){
b=b*a;
2 b=b-
4 1;}
c=b+d;
3
Example
int f1(int x,int
1
y){
if (x>y) 2
1 whilethen
(x !=
2 3 4
y){
x=x-y;
5
5 }else y=y-x;
3 6
6 return x;
}
4
Path
A path through a program:
a node and edge sequence from
areas + 1
Bounded area
Any region enclosed by nodes
and edge sequence.
Example Control Flow
Graph
1
2
3 4
5
6
Example
From a visual examination of the
CFG:
the number of bounded areas is
2.
cyclomatic complexity =
2+1=3.
Cyclomatic complexity
independent paths.
Prepare test cases:
path.
Example
int f1(int x,int
y){
2 if (x>y)
1 whilethen
(x !=
y){
3 x=x-y;
4 else y=y-x;
6 return x;
}
5}
Example Control Flow
Diagram
1
2
3 4
5
6
Derivation of Test Cases
Cyclomatic complexity of a
program:
also indicates the psychological
complexity of a program.
difficulty level of understanding
the program.
Cyclomatic complexity
value.
Good software development
organizations:
restrict cyclomatic complexity of
functions to a maximum of ten.
Types of failure