|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Testable
A semantic interface indicating the class has a static test method.
When a class implements this semantic marker interface, it indicates
that it defines a static test method with the following signature:
public static boolean test ( String [ ] args )
This method performs one or more unit self-tests for the class that it is defined in, returning true if the tests were successful and false if otherwise. It may perform white-box or black-box testing.
When provided with a null or empty String array argument, it performs its default test. The default test must not have persistent side-effects such as creating files or modifying static variables nor attempt operations that have nuisance effects. The default test may write to the standard output and the standard error to facilitate debugging. If provided with a non-empty String array argument, it may run tests that have persistent side-effects.
The test method can be called by the class main method, passing the
command-line arguments as the test method arguments. This makes it
easy to test the class from the command-line during development.
Note that if no command-line arguments are specified, the argument
is an empty String array and the default test will be run.
public static void main ( String [ ] args )
{
System.out.println ( test ( args ) );
}
Automated testing of all the classes in a library can be performed using reflection to test if a class implements the interface Testable. If the class does, its test method can be called using reflection and the boolean result reported along with anything written to the standard output and standard error. If a class contains a test method that conforms to the required signature but it does not implement the semantic interface Testable, the test method should not be executed as the similarity may be coincidental.
|
CroftSoft Javadoc | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |