satin.testing
Class TestProgram

java.lang.Object
  |
  +--satin.testing.Test
        |
        +--satin.testing.TestProgram
Direct Known Subclasses:
TestScript, TestSuite

public abstract class TestProgram
extends Test

Base class for a test that is independently runnable as a separate program. This class provides the following support:

Command-Line Arguments

The TestProgram class recognizes the following command-line switches:

-logFile fileName
Specifies the name of the log file. If this switch is not given, the log file name will be taken from the name of the test script class that contains the main method.
-appendLog
If this switch is given and the log file already exists, the log file is appended. If this switch is not given and the log file already exists, the log file is replaced.
-echoLog
This switch causes all log output to be written to the standard output (as well as to the log file).
-autoFlush
This switch enables the autoFlush variable in the LogFile object, which causes each line of output to be flushed to disk immediately after it is written.
Your derived class can define and handle its own command-line arguments by overriding the defineCmdLineArgs method.

Author:
Ed Stauff

Field Summary
TestLog log
          The log for this test program.
 
Fields inherited from class satin.testing.Test
lastException
 
Constructor Summary
TestProgram(TestLog log, java.lang.String[] cmdLineArgs)
          The constructor.
 
Method Summary
protected static TestLogInternal createLogFile(java.lang.String programName, boolean append)
          Creates the log file.
protected abstract void createParams()
          Creates the parameter set for the test program.
protected void defineCmdLineArgs(CmdLineParser p)
          Defines command line arguments.
protected boolean doSetup()
          Performs the setup phase, catching and reporting any exceptions.
final TestLog getLog()
          Returns the log file.
 
Methods inherited from class satin.testing.Test
cleanup, doCleanup, doExecute, doVerify, execute, run, setup, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public TestLog log
The log for this test program. All test output should be directed to this log. You can use this field or the getLog method interchangeably. Never change the value of this field!
Constructor Detail

TestProgram

public TestProgram(TestLog log,
                   java.lang.String[] cmdLineArgs)
            throws java.lang.Exception
The constructor.

Parameters:
log
the log file to append to, or null to create a new one.
cmdLineArgs
arguments passed to the command line. If there are no command line arguments, you can pass null for this parameter.
Method Detail

defineCmdLineArgs

protected void defineCmdLineArgs(CmdLineParser p)
Defines command line arguments. You can override this in your derived class to define arguments that are specific to your script. All you need to do is call the appropriate define*** methods of CmdLineParser. If you override this method, be sure to call the inherited method first, before defining your own arguments.

doSetup

protected boolean doSetup()
                   throws java.io.IOException
Description copied from class: Test
Performs the setup phase, catching and reporting any exceptions. Do not override this method; override setup instead. Do not call this method from any method except run.

Overrides:
doSetup in class Test

Following copied from class: satin.testing.Test

Returns:
false if setup threw an exception; true otherwise.

createParams

protected abstract void createParams()
                              throws ParamError
Creates the parameter set for the test program.

createLogFile

protected static TestLogInternal createLogFile(java.lang.String programName,
                                               boolean append)
                                        throws java.io.IOException
Creates the log file. You can override this to create a log file which is a subclass of TestLogInternal.

getLog

public final TestLog getLog()
Returns the log file. This method must never return null. You can use this method or the log field interchangeably; this method is provided for use in the base Test class, which does not have access to a log field.

Overrides:
getLog in class Test
Revision History

7/31/01 Ed Stauff - made changes per code review.

5/31/01 Ed Stauff - removed final from log field; made programName field package scope instead of public; replaced handleCmdLine and printHelp with defineCmdLineArgs.

4/10/01 Ed Stauff - file created.



Generated on 5/9/2001 19:37 from TestProgram.java (PRIVATE SOURCES)