public class SpringFailOnTimeout
extends org.junit.runners.model.Statement
SpringFailOnTimeout is a custom JUnit Statement which adds
support for Spring's @Timed
annotation by throwing an exception if the next statement in the execution
chain takes more than the specified number of milliseconds.
In contrast to JUnit's
FailOnTimeout,
the next statement will be executed in the same thread as the
caller and will therefore not be aborted preemptively.
evaluate()| Constructor and Description |
|---|
SpringFailOnTimeout(org.junit.runners.model.Statement next,
long timeout)
Construct a new
SpringFailOnTimeout statement for the supplied
timeout. |
SpringFailOnTimeout(org.junit.runners.model.Statement next,
Method testMethod)
Construct a new
SpringFailOnTimeout statement for the supplied
testMethod, retrieving the configured timeout from the
@Timed annotation on the supplied method. |
| Modifier and Type | Method and Description |
|---|---|
void |
evaluate()
Evaluate the next
statement in the execution chain
(typically an instance of SpringRepeat) and throw a
TimeoutException if the next statement executes longer
than the specified timeout. |
public SpringFailOnTimeout(org.junit.runners.model.Statement next,
Method testMethod)
SpringFailOnTimeout statement for the supplied
testMethod, retrieving the configured timeout from the
@Timed annotation on the supplied method.next - the next Statement in the execution chaintestMethod - the current test methodTestAnnotationUtils.getTimeout(Method)public SpringFailOnTimeout(org.junit.runners.model.Statement next,
long timeout)
SpringFailOnTimeout statement for the supplied
timeout.
If the supplied timeout is 0, the execution of the
next statement will not be timed.
next - the next Statement in the execution chain; never nulltimeout - the configured timeout for the current test, in milliseconds;
never negativepublic void evaluate()
throws Throwable
statement in the execution chain
(typically an instance of SpringRepeat) and throw a
TimeoutException if the next statement executes longer
than the specified timeout.evaluate in class org.junit.runners.model.StatementThrowable