|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--junit.framework.Assert
|
+--junit.extensions.TestDecorator
|
+--com.clarkware.junitperf.TimedTest
The TimedTest is a test decorator that
runs a test and measures the elapsed time of the test.
A TimedTest is constructed with a specified
maximum elapsed time. By default, a TimedTest
will wait for the completion of its decorated test and
then fail if the maximum elapsed time was exceeded.
Alternatively, a TimedTest can be constructed
to immediately signal a failure when the maximum elapsed time
of its decorated test is exceeded. In other words, the
TimedTest will not wait for its decorated
test to run to completion if the maximum elapsed time is
exceeded.
For example, to decorate the ExampleTest
as a TimedTest that waits for the
ExampleTest to run to completion and
then fails if the maximum elapsed time of 2 seconds
is exceeded, use:
or, alternatively, use:Test timedTest = new TimedTest(new ExampleTest(), 2000);
Test timedTest = new TimedTest(new ExampleTest(), 2000, true);
Alternatively, to decorate the ExampleTest
as a TimedTest that fails immediately when
the maximum elapsed time of 2 seconds is exceeded, use:
Test timedTest = new TimedTest(new ExampleTest(), 2000, false);
TestDecorator| Fields inherited from class junit.extensions.TestDecorator |
fTest |
| Constructor Summary | |
TimedTest(junit.framework.Test test,
long maxElapsedTime)
Constructs a TimedTest to decorate the
specified test with the specified maximum elapsed time. |
|
TimedTest(junit.framework.Test test,
long maxElapsedTime,
boolean waitForCompletion)
Constructs a TimedTest to decorate the
specified test with the specified maximum elapsed time. |
|
| Method Summary | |
int |
countTestCases()
Returns the number of tests in this test. |
boolean |
outOfTime()
Determines whether the maximum elapsed time of the test was exceeded. |
void |
run(junit.framework.TestResult result)
Runs the test. |
protected void |
runUntilTestCompletion(junit.framework.TestResult result)
Runs the test until test completion and then signals a failure if the maximum elapsed time was exceeded. |
protected void |
runUntilTimeExpires(junit.framework.TestResult result)
Runs the test and immediately signals a failure when the maximum elapsed time is exceeded. |
java.lang.String |
toString()
Returns the test description. |
| Methods inherited from class junit.extensions.TestDecorator |
basicRun, getTest |
| Methods inherited from class junit.framework.Assert |
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public TimedTest(junit.framework.Test test,
long maxElapsedTime)
TimedTest to decorate the
specified test with the specified maximum elapsed time.
The TimedTest will wait for the completion
of its decorated test and then fail if the maximum elapsed
time was exceeded.
test - Test to decorate.maxElapsedTime - Maximum elapsed time (ms).
public TimedTest(junit.framework.Test test,
long maxElapsedTime,
boolean waitForCompletion)
TimedTest to decorate the
specified test with the specified maximum elapsed time.test - Test to decorate.maxElapsedTime - Maximum elapsed time (ms).waitForCompletion - true (default) to
indicate that the TimedTest should wait
for its decorated test to run to completion and then
fail if the maximum elapsed time was exceeded;
false to indicate that the
TimedTest should immediately signal
a failure when the maximum elapsed time is exceeded.| Method Detail |
public int countTestCases()
countTestCases in class junit.extensions.TestDecoratorpublic boolean outOfTime()
true if the max elapsed time
was exceeded; false otherwise.public void run(junit.framework.TestResult result)
run in class junit.extensions.TestDecoratorresult - Test result.protected void runUntilTestCompletion(junit.framework.TestResult result)
result - Test result.protected void runUntilTimeExpires(junit.framework.TestResult result)
result - Test result.public java.lang.String toString()
toString in class junit.extensions.TestDecorator
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||