Java Reference
In-Depth Information
plus 1. Test cases that use these cases, plus at least one from within the general
field of the category, should be defined.
Let's look at an example. Consider a method whose purpose is to validate that
a particular integer value is in the range 0 to 99, inclusive. There are three equiva-
lence categories in this case: values below 0, values in the range of 0 to 99, and
values above 99. Black-box testing dictates that we use test values that surround
and fall on the boundaries, as well as some general values from the equivalence
categories. Therefore, a set of black-box test cases for this situation might be:
−500, −1, 0, 1, 50, 98, 99, 100, and 500.
White-box testing,
also known as
glass-box testing,
exercises the internal struc-
ture and implementation of a method. A white-box test case is based on the logic
of the code. The goal is to ensure that every path through a program is executed at
least once. A white-box test maps the possible paths through the code and ensures
that the test cases cause every path to be executed. This type of testing is often
called
statement coverage.
Paths through code are controlled by various control flow statements that
use conditional expressions, such as
if
statements. In order to have every path
through the program executed at least once, the input data values for the test
cases need to control the values for the conditional expressions. The input data of
one or more test cases should cause the condition of an
if
statement to evaluate
to
true
in at least one case and to
false
in at least one case. Covering both true
and false values in an
if
statement guarantees that both the paths through the
if
statement will be executed. Similar situations can be created for loops and other
constructs.
In both black-box and white-box testing, the expected output for each test
should be established prior to running the test. It's too easy to be persuaded that
the results of a test are appropriate if you haven't first carefully determined what
the results should be.
SELF-REVIEW QUESTION
(see answer in Appendix N)
SR 7.25
Select the term from the following list that best matches each of the
following phrases:
black-box, defects, regression, review, test case, test suite, walk-
through, white-box
a. Running previous test cases after a change is made to a program
to help ensure that the change did not introduce an error.
b. A meeting in which several people collectively evaluate an artifact.
c. A review that steps carefully through a document, evaluating each
section.
d. The goal of testing is to discover these.
Search WWH ::
Custom Search