White Box Testing
White Box Testing
White Box Testing
by :
Oerip S. Santoso
Introduction
• White Box Testing or Glass Box Testing
– Test case design method that uses the control structure of the procedural
design to derive test cases
• SW Engineer can derive test cases that
– guarantee that all independent paths within a module have been exercised
at least once
– exercise all logical decisions on their true and false bounds
– execute all loops at their boundaries and within their operational bounds
– exercise internal data structures to assure their validity
• Why not just validate the requirement ?
– Logic errors and incorrect assumptions are inversely proportional to the
probability that a program path will be executed
– We often believe that a logical path is not likely to be executed when, in
fact, it may be executed on a regular basis
– Typographical errors are random
While
Sequence
Case
Repeat - Until
11
12
1
2,3
2
7
4 8 9,10 4,5,6
7
9 5
8
11
10 6
11 12
12
Predicate Node
IF a or b
b
then procedure X
else procedure Y
y x x
endif
V(G) = E - N + 2
V(G) = 9 - 8 + 2
=3
path 1: 1-13
1
path 2: 1-2-3-7-8-11-12-1-13
2,3 path 3: 1-2-3-7-9-10-11-12-1-13
7
path 4: 1-2-3-4-5-6-12-1-13
Nested Loops
Concatenated
Simple Loops
Loops
Unstructured
Loops
12/2/03 Bayu Hendradjaya - http://www.if.itb.ac.id/~bayu 16
Loop Testing (2)
• To test:
• Simple Loops of size n:
• Skip loop entirely
• Only one pass through loop
• Two passes through loop
• m passes through loop where m<n.
• (n-1), n, and (n+1) passes through the loop.
• Nested Loops
• Start with inner loop. Set all other loops to minimum values.
• Conduct simple loop testing on inner loop.
• Work outwards
• Continue until all loops tested.
• Concatenated Loops
• If independent loops, use simple loop testing.
• If dependent, treat as nested loops.
• Unstructured loops
• Don't test - redesign.
12/2/03 Bayu Hendradjaya - http://www.if.itb.ac.id/~bayu 17