All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cryptix.util.test.BaseTest

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----cryptix.util.test.BaseTest

public abstract class BaseTest
extends Applet
This abstract class acts as a base for all Cryptix test classes. Its purpose is to provide a framework that will allow us to easily add new testing features. Features that have already been added include:

Planned features include:

Copyright © 1997, 1998 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.5 $

Author:
David Hopwood

Variable Index

 o out
The PrintWriter to which delayed output is sent.
 o status
The PrintWriter to which immediate output is sent.

Constructor Index

 o BaseTest()
Constructor for use by subclasses.

Method Index

 o commandline(String[])
Used to run a test from the command line.
 o commandline(String[], int)
Used to run a test from the command line, skipping the first offset arguments (which are assumed to have been processed by the subclass).
 o describeOptions()
Describes the command-line options of this class.
 o describeUsage()
Describes the command-line usage of this class.
 o engineTest()
This method should be overridden by test subclasses, to perform the actual testing.
 o error(Exception)
Reports an error due to an unexpected exception.
 o error(String)
Reports an error, with the given message.
 o error(Throwable)
 o fail(String)
Reports a failure, with the given message.
 o getErrors()
Returns the number of errors so far.
 o getExpectedPasses()
Returns the number of expected passes, or 0 if this has not yet been set, or is unknown.
 o getFailures()
Returns the number of failures so far.
 o getName()
Gets the name of this test (as shown to the user).
 o getPasses()
Returns the number of passes so far.
 o getSkipped()
Returns the number of skipped tests so far.
 o init()
Used when the test is running as an Applet.
 o isGuiEnabled()
Returns true iff a GUI interface is being used.
 o isOverallPass()
Returns true iff all the tests have completed successfully.
 o isVerbose()
Returns true iff output is to be printed even if all tests pass.
 o parseOption(String)
Parses a command-line option.
 o parseOptions(String[], int)
Processes command-line arguments from args, starting at index offset.
 o pass(String)
Reports a pass, with the given message.
 o passIf(boolean, String)
Reports a pass if pass is true, or a failure if it is false.
 o report()
Forces a report of the number of passes, failures, errors, and expected passes so far.
 o setExpectedPasses(int)
Sets the number of expected passes for this test class.
 o setGuiEnabled(boolean)
Sets whether a GUI interface is used.
 o setName(String)
Sets the name of this test (as shown to the user).
 o setOutput(PrintWriter)
Sets the PrintWriter to which output is to be sent.
 o setVerbose(boolean)
Sets whether output is to be printed even if all tests pass.
 o skip(String)
Reports a skipped test, with the given message.
 o test()
Begins the test proper.
 o waitForExit()
Blocks until it is time to exit.

Variables

 o status
 protected PrintWriter status
The PrintWriter to which immediate output is sent.

 o out
 protected PrintWriter out
The PrintWriter to which delayed output is sent.

Constructors

 o BaseTest
 protected BaseTest()
Constructor for use by subclasses.

Methods

 o init
 public synchronized void init()
Used when the test is running as an Applet.

Overrides:
init in class Applet
 o setGuiEnabled
 public synchronized void setGuiEnabled(boolean flag)
Sets whether a GUI interface is used.

 o isGuiEnabled
 public boolean isGuiEnabled()
Returns true iff a GUI interface is being used.

 o waitForExit
 public synchronized void waitForExit()
Blocks until it is time to exit.

 o commandline
 protected void commandline(String args[])
Used to run a test from the command line. Each test class' main method should create an instance and call the commandline method on it, passing the array of command line arguments. For example, in class TestFoo:
    public static void main(String[] args) {
        new TestFoo().commandline(args);
    }
 

 o commandline
 protected void commandline(String args[],
                            int offset)
Used to run a test from the command line, skipping the first offset arguments (which are assumed to have been processed by the subclass).

 o parseOption
 protected void parseOption(String option) throws TestException
Parses a command-line option. If the option is not recognised, super.parseOption(option) should be called.

Case should generally not be significant in option names.

 o parseOptions
 public void parseOptions(String args[],
                          int offset) throws TestException
Processes command-line arguments from args, starting at index offset.

 o describeUsage
 public String describeUsage()
Describes the command-line usage of this class.

 o describeOptions
 public String describeOptions()
Describes the command-line options of this class.

 o setName
 public void setName(String n)
Sets the name of this test (as shown to the user). The default is the name of the class.

Overrides:
setName in class Component
 o getName
 public String getName()
Gets the name of this test (as shown to the user).

Overrides:
getName in class Component
 o setOutput
 public void setOutput(PrintWriter pw)
Sets the PrintWriter to which output is to be sent. In most cases this does not need to be set by the test class; the commandline method will do that automatically.

 o setVerbose
 public void setVerbose(boolean flag)
Sets whether output is to be printed even if all tests pass.

 o isVerbose
 public boolean isVerbose()
Returns true iff output is to be printed even if all tests pass.

 o test
 public void test() throws TestException
Begins the test proper. This method is called automatically by commandline, but it can also be called directly.

 o fail
 protected void fail(String msg)
Reports a failure, with the given message.

 o error
 protected void error(String msg)
Reports an error, with the given message.

 o skip
 protected void skip(String msg)
Reports a skipped test, with the given message.

 o error
 protected void error(Exception e)
Reports an error due to an unexpected exception.

 o error
 protected void error(Throwable e)
 o pass
 protected void pass(String msg)
Reports a pass, with the given message.

 o passIf
 protected void passIf(boolean pass,
                       String msg)
Reports a pass if pass is true, or a failure if it is false. In either case, the given message is used.

 o setExpectedPasses
 protected void setExpectedPasses(int n)
Sets the number of expected passes for this test class. This can be called at any time by the engineTest method, but should normally be called at the start of that method.

 o report
 protected void report()
Forces a report of the number of passes, failures, errors, and expected passes so far.

 o getFailures
 public int getFailures()
Returns the number of failures so far.

 o getErrors
 public int getErrors()
Returns the number of errors so far.

 o getPasses
 public int getPasses()
Returns the number of passes so far.

 o getSkipped
 public int getSkipped()
Returns the number of skipped tests so far.

 o getExpectedPasses
 public int getExpectedPasses()
Returns the number of expected passes, or 0 if this has not yet been set, or is unknown.

 o isOverallPass
 public boolean isOverallPass()
Returns true iff all the tests have completed successfully.

 o engineTest
 protected abstract void engineTest() throws Exception
This method should be overridden by test subclasses, to perform the actual testing.


All Packages  Class Hierarchy  This Package  Previous  Next  Index