Black-Box (Functional) White-Box (Structural) : Testing Methods
Black-Box (Functional) White-Box (Structural) : Testing Methods
Black-Box (Functional) White-Box (Structural) : Testing Methods
Black-box (functional)
White-box (structural)
– Background
– Statement coverage
– Decision coverage
– (Short circuit) condition coverage
– Dataflow coverage
Coverage terminology
Coverage tools
1
Black-Box Testing
2
Equivalence Partitioning
On inputs:
– Identify input variables
e.g. side lengths, number of sides
– Identify valid and invalid value sets for each variable
e.g. fl j l > 0g valid; fl j l 0g invalid; fl j l not a numberg invalid
– Build complete test cases from those sets
e.g. (3, 4, 5), (-1, 3, 3), (3, a, 3), (3), (3, 4, 5, 6, 7)
On outputs:
– Identify output events, output variables, (sets of) variable values
e.g. triangle types, angle types
– Build test cases that generate each one
e.g. (3, 3, 3), (2, 2, 3), (3, 4, 5), (2, 10, 2)
3
Boundary Value Analysis
4
Extreme Value Analysis
Find an n again
Choose extremely large/small values for n
Generate test cases for each
n can be integer or real
n can be input value, output value, number of repetitions/occurrences,
etc.
For TRIANGLE:
– On inputs/outputs: (0.000004, 0.000002, 0.000003), (43728947,
43928410, 54386880)
– On number of repetitions: () (empty test case), (3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3)
5
Syntax Testing
-f
put -g filename
-m filename
get filename
Basic steps:
– Identify target language and make explicit if not already
– Define syntax formally with state machine
– Write test cases to cover:
– All transitions
– All incomplete inputs
– Each change of a valid token to an invalid one
For above grammar: (put -f foo), (put -g foo), (put -m foo bar), (get foo), (put -f), (get),
(put -f -g), . . .
6
White-Box Testing
7
Statement Coverage
premium = 500;
if ((age<25) && (sex==male) && (!married)) {
premium += 1500;
} else {
if (married || (sex==female)) {
premium -= 200;
}
if ((age>45) && (age<65)) {
premium -= 100;
}
}
8
Statement Coverage
9
Decision Coverage
10
(Short-Circuit) Condition Coverage
11
Comparing Coverage Criteria
12
Dataflow Coverage
13
Def-Use Coverage
14
Coverage Terminology
A test suite achieves (90%) statement coverage on code if 90% of the statements are exe-
cuted
– Similarly 90%, 80%, etc., decision coverage, def-use coverage, etc.
Some statements cannot be executed (“dead code”)
– Consider these coverage elements infeasible for statement coverage
– Similarly, infeasible decisions, conditions, etc.
Generally only count feasible coverage elements
– Thus say “100% feasible statement coverage”, etc.
Minimal test suite for a criterion: one that achieves the criterion in the smallest number of
test cases
15
Coverage Tools
16