Java Reference
In-Depth Information
because of the number of possible test cases. Even if a method has only
one int parameter, exhaustive testing would require calling the method
well over four billion times, and the output of each call would have to be
checked for correctness.
2. Blackbox testing, or functional testing . In making up test cases, one
looks only at the specification of the program (and not the program itself)
in deciding what test cases to try. The program is a black box, and you
cannot see inside it.
Lesson page 14-3
has a discussion
of blackbox test-
ing and an inter-
esting anecdote
about doing it in
industry.
3. Whitebox testing, or structural testing . One looks at the program itself
when developing test cases and uses the structure of the program to rec-
ognize possible trouble spots and develop test cases to exercise them.
The term whitebox testing was badly chosen. Just because a box is
white does not mean you can see through it. A better term would have
been glassbox testing or transparent box testing .
In the rest of this section, we discuss structural testing as a complement to
functional testing. We review maxim 3:
/** = English equivalent of n , for 0<n<1000 */
public static String anglicize( int n) {
String s= " " ; // anglicize(n) = s + anglicize(k)
int k= n;
if (k >= 100) {
s= s + digitName(k / 100) + "hundred ";
k= k % 100;
}
if (k >= 20) {
s= s + tensName(k / 10);
k= k % 10;
}
if (k > 10) {
s= s + teenName(k);
k= 0;
}
if (k > 0) {
s= s + digitName(k);
k= 0;
}
return s;
}
Figure 14.4:
Method anglicize , to be tested (it contains an error)
Search WWH ::




Custom Search