spring-framework / org.springframework.test.context.junit4.statements / SpringFailOnTimeout

SpringFailOnTimeout

open class SpringFailOnTimeout : Statement

SpringFailOnTimeout is a custom JUnit Statement which adds support for Spring's org.springframework.test.annotation.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 org.junit.internal.runners.statements.FailOnTimeout, the next statement will be executed in the same thread as the caller and will therefore not be aborted preemptively.

Author
Sam Brannen

Since
3.0

See Also
#evaluate()

Constructors

<init>

SpringFailOnTimeout(next: Statement, testMethod: Method)

Construct a new SpringFailOnTimeout statement for the supplied testMethod, retrieving the configured timeout from the @Timed annotation on the supplied method.

SpringFailOnTimeout(next: Statement, timeout: Long)

Construct a new SpringFailOnTimeout statement for the supplied timeout.

If the supplied timeout is 0, the execution of the next statement will not be timed.

Functions

evaluate

open fun evaluate(): Unit

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.