Test levels and methods
Black-box testing
Black-box testing checks a system only through its interfaces, without knowledge of its internal structure. Its counterpart is white-box testing, which deliberately exercises the code and its structure.
Also known as: black-box test, functional testing, white-box testing, glass-box testing
Black box: viewed from outside
In black-box testing, all that matters is what goes in and what comes out. Test cases come from requirements and specifications, not from the code. Typical techniques are equivalence partitioning and boundary value analysis.
The advantage: the tests stay valid even if the implementation is completely rebuilt. System and acceptance tests are almost always black-box tests.
White box: looking into the code
In white-box testing, cases are derived from the structure of the code: every branch, every condition, every loop should run at least once. This is measured as test coverage. White-box tests are typical of unit tests.
Combining both
Black-box tests show whether the system does the right thing. White-box tests show whether every path has been thought through. In between sits grey-box testing, which uses knowledge of the internals to write more targeted black-box tests.