|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | CONST | FIELD | CONSTR | METHOD | DETAIL: CONST | FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--satin.testing.Test
public abstract class Test
extends java.lang.Object
This is an abstract base class for all tests, including
Testcase,
TestScript,
TestGroup and
TestSuite.
The fundamental architecture for using a Test object is:
Test object, passing it any parameters
it may need.
Test object at most once by calling the
run method (which
takes no arguments).
TestScript is an exception;
it gets it parameters from a parameter file.)
run method calls
setup,
execute
verify
and cleanup in turn.
Separating a test into these phases helps improve error reporting:
if a test fails during setup, it means that the actual test itself was
never performed; if a test fails during execute or verify, it gives a clearer
indication that the feature under test does not work.
The Test class takes care of catching all exceptions and logging them
to a TestLog.
In practice, most actual test classes will derive from
Testcase,
TestScript or
TestGroup.
| Field Summary | |
protected java.lang.Exception |
lastException
The most recent exception that was caught by doSetup, doExecute, doVerify, or doCleanup. |
| Constructor Summary | |
protected |
Test()
The constructor. |
| Method Summary | |
protected void |
cleanup()
Override this method to perform test-specific cleanup. |
protected boolean |
doCleanup()
Performs the cleanup phase, catching and reporting any exceptions. |
protected boolean |
doExecute()
Performs the execution phase, catching and reporting any exceptions. |
protected boolean |
doSetup()
Performs the setup phase, catching and reporting any exceptions. |
protected boolean |
doVerify()
Performs the verification phase, catching and reporting any exceptions. |
protected abstract void |
execute()
Override this method to perform the test. |
abstract TestLog |
getLog()
Returns the log file. |
final boolean |
run()
Runs the test. |
protected void |
setup()
Override this method to perform test-specific setup. |
protected void |
verify()
Override this method to verify the results of the test. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.lang.Exception lastException
| Constructor Detail |
protected Test()
| Method Detail |
public final boolean run()
throws java.lang.Exception
setup method is called first.
If setup runs without throwing an exception, then the
execute method is called.
If execute runs without throwing an exception, then the
verify method is called.
The cleanup method is called last,
regardless of whether setup, execute or
verify threw an exception.
All Exceptions are logged to the test log
returned by getLog.
Errors, however, are neither caught nor logged,
as they indicate programming errors.
Each test object can be run at most once. If you try to run a test more than once, an assertion will fail. If you need to run a test more than once, you must instantiate it once for each run.
You should normally not override this method.
protected boolean doSetup()
throws java.io.IOException
setup
instead.
Do not call this method from any method except
run.
setup threw an exception; true otherwise.
protected boolean doExecute()
throws java.io.IOException
execute instead.
Do not call this method from any method except
run.
execute threw an exception; true otherwise.
protected boolean doVerify()
throws java.io.IOException
verify instead.
Do not call this method from any method except
run.
execute threw an exception; true otherwise.
protected boolean doCleanup()
throws java.io.IOException
cleanup instead.
Do not call this method from any method except
run.
cleanup threw an exception; true otherwise.
protected void setup()
throws java.lang.Exception
execute method from being called.
You can perform the setup for your test in your execute
method instead, but putting it here can provide clearer error reporting.
protected abstract void execute()
throws java.lang.Exception
protected void verify()
throws java.lang.Exception
execute ran without throwing
an exception.
Any exceptions thrown by this method will be caught and logged.
You can perform the verification for your test in your execute
method instead, but putting it here can provide clearer error reporting.
protected void cleanup()
throws java.lang.Exception
setup,
execute or verify threw an exception.
Any exceptions thrown by this method will be caught and logged.public abstract TestLog getLog()
| Revision History |
7/31/01 Ed Stauff - code review.
6/27/01 Ed Stauff - added lastException field.
5/31/01 Ed Stauff - made run final.
5/15/01 Ed Stauff - changes per 2nd API review.
3/27/01 Ed Stauff - made changes per API review.
3/22/01 - reviewed by Test Automation team.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | CONST | FIELD | CONSTR | METHOD | DETAIL: CONST | FIELD | CONSTR | METHOD | ||||||||
Test.java (PRIVATE SOURCES)