public class TestDriver
extends java.lang.Object
TestFrame overview. Compared to other test frameworks, TestFrame may seem very simple. Do not confuse this with lack of capability. TestFrame was designed to provide precisely what is needed to implement a set of component tests, without a lot of extra fluff. Everything that is provided is needed, and everything that is provided has a well defined meaning. Other frameworks provide a large number of methods and capabilities that are not well defined, often resulting in multiple ways to do things. While having multiple redundant ways to do things may seem initially as a good thing, it leads to different developers setting things up in different ways, with the result that the entire test set is harder to manage. The goal with "TestFrame" is to provide a single clear way to write the test so that it is easier for developers to write tests that are consistent, and as a result easier to maintain.
You need to understand two classes and one interface in order to write a component test.
Usage of TestDrive is very easy. THere are two methods. The first passes the name of a single test class to invoke that class. The second is the name of a text file. This text file contains a list of names of testclasses to be invoked.
That is all there is to it. Define a test which implements TestSet. That test can make use of any routines, any support libraries. It can go read files (although be careful not to hard code the path). It can run any number of individual tests. It can even, if it chooses, call other classes that implement TestSet. Essentually you have the full power of Java at your disposal, so use it.
TestRecorder,
Author: Keith Swenson| Modifier and Type | Method and Description |
|---|---|
static void |
deparenthesize(java.io.Writer out,
java.lang.String input)
Formats an exception message in order to print out a cascaded exception
correctly.
|
static void |
DriveTests(TestRecorderText tr,
java.lang.String[] args)
DriveTestsWithRecorder - allows an external program to create a test
recorder and pass it to this, but otherwise drive the tests in the same
manner.
|
static void |
main(java.lang.String[] args)
This program can be used with these parameters:
TestDriver myTestList.txt param param param
TestDriver myTest.class param param param
The parameter is the name of a text file that contains the list of
command lines: the first token on the line must be the test class, and
the rest of the parameters work like command line parameters, only note:
each parameter must be separated by exactly one space, and there is no
support for quote symbols to allow spaces within a parameter.
|
public static void deparenthesize(java.io.Writer out,
java.lang.String input)
throws java.lang.Exception
It converts a string with multiple nested curley braces into a sequence of lines, indented one additional space for every level of nesting.
It is not likely that a test writer will need this, because a test should simple throw an exception, and almost never catch them, and in any case should never be printing them out. Instead an exception is reported through the TestRecorder.fatal method.
java.lang.Exceptionpublic static void DriveTests(TestRecorderText tr, java.lang.String[] args) throws java.lang.Exception
java.lang.Exceptionpublic static void main(java.lang.String[] args)