things.testing.unit
Class Test

java.lang.Object
  extended by things.testing.unit.Test
Direct Known Subclasses:
DeadTest

public abstract class Test
extends java.lang.Object

UNIT testing tool. This is a test. It will run a set of test cases. A test is implemented by the following steps:
1- Implement the test_prepare() method. Test cases will be DECLARED(String) by name.
2- Implement the test_execute() method. Each case should be reported with a PASS(), FAIL(), INCONCLUSIVE(), or EXCEPTION(). You may use ABORT() at any time to abort the remaining tests.
3- Call the test in a TestGroup

You should not call any other method in this class.

The result fields are readable after the test is run.

Version:
1.0

Version History

 EPG - Initial - 26 JUL 04
 EPG - Re-write - 19 JUN 05
 
Author:
Erich P. Gatejen

Field Summary
 int abort
           
 int exception
           
 int fail
           
 int inconclusive
           
 int pass
           
protected  ThingsPropertyView properties
          Properties passed to the test by the harness.
 Result result
           
protected  java.lang.String testName
           
 long time
           
 int total
           
 long totalSize
           
 
Constructor Summary
Test()
           
 
Method Summary
 void ABORT(java.lang.String name, java.lang.String message)
          ABORT THIS TEST.
 void CODE(java.lang.String name, java.lang.String code)
          Set the CODE for the case.
 void COMMENT(java.lang.String name, java.lang.String message)
          COMMENT into the test report
 void DECLARE(java.lang.String name)
          DECLARE a test case.
 void EXCEPTION(java.lang.String name, java.lang.String message)
          EXCEPTION test case report
 void EXCEPTION(java.lang.String name, java.lang.Throwable theException)
          EXCEPTION test case report
 Result execute()
          Run the test.
 void FAIL(java.lang.String name, java.lang.String message)
          FAIL a test case report
 java.lang.String getLongName()
          Get the long name of this test.
 java.lang.String getName()
          Get the name of this test.
 void INCONCLUSIVE(java.lang.String name, java.lang.String message)
          INCONCLUSIVE test case report.
 void LOG(java.lang.String text)
          Log a comment.
 void PASS(java.lang.String name)
          PASS a test case report.
 void PASS(java.lang.String name, java.lang.String message)
          PASS a test case report with a message.
 void prepare(java.lang.String runnerNaming, java.lang.String givenName, ResultExpresser expresserIn, StringPoster log, ThingsPropertyView view, int inDepth)
          Prepare for the test.
static void PUNT(java.lang.String text)
          PUNT is a simple convenience that tosses a test fail exception.
 void SET_LONG_NAME(java.lang.String name)
          Set the long name for this test.
 void SIZE(java.lang.String name, long size)
          Set the SIZE for the case.
abstract  void test_execute()
          Run the test.
abstract  void test_prepare()
          Prepare for the test.
 void TIME(java.lang.String name, long time)
          Set the TIME for the case.
 void VALUE(java.lang.String name, java.lang.String n, java.lang.String v)
          Set a VALUE for the case.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

total

public int total

pass

public int pass

fail

public int fail

abort

public int abort

inconclusive

public int inconclusive

exception

public int exception

time

public long time

totalSize

public long totalSize

result

public Result result

properties

protected ThingsPropertyView properties
Properties passed to the test by the harness. Feel free to use them.


testName

protected java.lang.String testName
Constructor Detail

Test

public Test()
Method Detail

test_prepare

public abstract void test_prepare()
                           throws java.lang.Throwable
Prepare for the test. Overload this with the test implementation.

Throws:
java.lang.Throwable

test_execute

public abstract void test_execute()
                           throws java.lang.Throwable
Run the test. Overload this with the test implementation.

Throws:
java.lang.Throwable

LOG

public void LOG(java.lang.String text)
         throws ThingsException
Log a comment. This is not a way to report results! Use these sparingly. It is perfectly acceptable to use a COMMENT instead.

Parameters:
text - the text of the comment
Throws:
ThingsException

DECLARE

public void DECLARE(java.lang.String name)
             throws ThingsException
DECLARE a test case. This should be called by test_prepare() to define the various tests.

Parameters:
name - the name of the test. It should be unique
Throws:
ThingsException

PASS

public void PASS(java.lang.String name,
                 java.lang.String message)
          throws ThingsException
PASS a test case report with a message.

Parameters:
name - test name
message - information
Throws:
ThingsException

PASS

public void PASS(java.lang.String name)
          throws ThingsException
PASS a test case report.

Parameters:
name - test name
Throws:
ThingsException

EXCEPTION

public void EXCEPTION(java.lang.String name,
                      java.lang.String message)
               throws ThingsException
EXCEPTION test case report

Parameters:
name - test name
message - information
Throws:
ThingsException

EXCEPTION

public void EXCEPTION(java.lang.String name,
                      java.lang.Throwable theException)
               throws ThingsException
EXCEPTION test case report

Parameters:
name - test name
theException - the exception that caused it
Throws:
ThingsException

FAIL

public void FAIL(java.lang.String name,
                 java.lang.String message)
          throws ThingsException
FAIL a test case report

Parameters:
name - test name
message - information
Throws:
ThingsException

ABORT

public void ABORT(java.lang.String name,
                  java.lang.String message)
           throws TestAbortException,
                  ThingsException
ABORT THIS TEST. It will halt the test. All unexecuted tests will be marked INCONCLUSIVE. It will still report on the test. Do NOT catch this exception in the test_execute() method. Let it bubble out.

Parameters:
name - test name
message - information
Throws:
TestAbortException
ThingsException

INCONCLUSIVE

public void INCONCLUSIVE(java.lang.String name,
                         java.lang.String message)
                  throws ThingsException
INCONCLUSIVE test case report.

Parameters:
name - test name
message - information
Throws:
ThingsException

TIME

public void TIME(java.lang.String name,
                 long time)
          throws ThingsException
Set the TIME for the case. The time should be in milliseconds.

Parameters:
name - test name
time - the time in milliseconds
Throws:
ThingsException

SIZE

public void SIZE(java.lang.String name,
                 long size)
          throws ThingsException
Set the SIZE for the case. The time should be in milliseconds.

Parameters:
name - test name
size - the size
Throws:
ThingsException

CODE

public void CODE(java.lang.String name,
                 java.lang.String code)
          throws ThingsException
Set the CODE for the case.

Parameters:
name - test name
code - the code
Throws:
ThingsException

VALUE

public void VALUE(java.lang.String name,
                  java.lang.String n,
                  java.lang.String v)
           throws ThingsException
Set a VALUE for the case.

Parameters:
name - test name
n - the name for the value
v - the value
Throws:
ThingsException

PUNT

public static void PUNT(java.lang.String text)
                 throws TestLocalException
PUNT is a simple convenience that tosses a test fail exception. It's useful for escaping local test case blocks. You MUST not let this exception escape the test_excute() method. This is a convenience for you to handle.

Parameters:
text - the text of the punt
Throws:
TestLocalException

COMMENT

public void COMMENT(java.lang.String name,
                    java.lang.String message)
             throws ThingsException
COMMENT into the test report

Parameters:
name - test name
message - information
Throws:
ThingsException

SET_LONG_NAME

public void SET_LONG_NAME(java.lang.String name)
Set the long name for this test. This can be useful for more information.

Parameters:
name - the long name as a string.

getName

public java.lang.String getName()
                         throws ThingsException
Get the name of this test.

Returns:
the name of this test
Throws:
ThingsException

getLongName

public java.lang.String getLongName()
                             throws ThingsException
Get the long name of this test.

Returns:
the name of this test
Throws:
ThingsException

prepare

public void prepare(java.lang.String runnerNaming,
                    java.lang.String givenName,
                    ResultExpresser expresserIn,
                    StringPoster log,
                    ThingsPropertyView view,
                    int inDepth)
             throws ThingsException
Prepare for the test. This will be called by the Group. Do not call it directly.

Parameters:
runnerNaming - is the name giving to the test run by the running agent
givenName - the name given to this test.
expresserIn - is the ResultExpresser to use.
log - a string poster used for logging non-result information.
view - is a preperties view that will be avaible to the test implementation
inDepth - the depth of this test.
Throws:
ThingsException
See Also:
ThingsPropertyView

execute

public Result execute()
               throws ThingsException
Run the test.

Returns:
a Result for this test.
Throws:
ThingsException


Things.