testing : Java Glossary
©1996-2017 Roedy Green of Canadian Mind Products
There are two basic methods of testing your code:
In a simple case, your test method can be the main
method of the class you are testing with the body of the method enclosed in:
- Unit testing: or white box testing. You write little
routines to exhaustively test each execution branch of your method. I often refer
to such a suite as a test harness. You test each method
in isolation. Unit tests are best at finding implementation errors, such as
off-by-one loops. Tools such as JUNIT (Java Unit test)
can help you compose these tests.
- Black-box testing: or system level testing. This is
best at finding integration errors. The tester deliberately does not look at how a
function is implemented. He is out to catch miscommunications between programmers
on how to use each others’ classes. The tester avoids looking at the code to
avoid falling into the same traps and presumptions the programmers did.
if ( DEBUGGING )where DEBUGGING is a static
final boolean. This code has a dual purpose of exercising the methods and
showing some sample uses and expected outputs.
For more complex classes, you use a tool like JUnit.