Java Reference
In-Depth Information
computers are used for credit analysis, and the analysis software has been
designed to deny credit systematically to certain groups of people (say, all
applicants with certain ZIP codes), is that illegal discrimination? What if the
software has not been designed in this fashion, but a neural network has ȓ
discoveredȓ a pattern from historical data? These are troubling questions,
especially because those that are harmed by such processes have little recourse.
5.5 Test Coverage
Testing the functionality of a program without consideration of its internal structure is
called black-box testing. This is an important part of testing, because, after all, the
users of a program do not know its internal structure. If a program works perfectly on
all inputs, then it surely does its job.
Black-box testing describes a testing method that does not take the structure of the
implementation into account.
However, it is impossible to ensure absolutely that a program will work correctly on
all inputs just by supplying a finite number of test cases. As the famous computer
scientist Edsger Dijkstra pointed out, testing can show only the presence of bugsȌnot
their absence. To gain more confidence in the correctness of a program, it is useful to
consider its internal structure. Testing strategies that look inside a program are called
white-box testing. Performing unit tests of each method is a part of white-box testing.
White-box testing uses information about the structure of a program.
You want to make sure that each part of your program is exercised at least once by
one of your test cases. This is called test coverage. If some code is never executed by
any of your test cases, you have no way of knowing whether that code would perform
correctly if it ever were executed by user input. That means that you need to look at
every if/else branch to see that each of them is reached by some test case. Many
conditional branches are in the code only to take care of strange and abnormal inputs,
but they still do something. It is a common phenomenon that they end up doing
something incorrectly, but those faults are never discovered during testing, because
nobody supplied the strange and abnormal inputs. Of course, these flaws become
immediately apparent when the program is released and the first user types in an
Search WWH ::




Custom Search