Class SpringFailOnTimeout
java.lang.Object
org.junit.runners.model.Statement
org.springframework.test.context.junit4.statements.SpringFailOnTimeout
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.
- Since:
- 3.0
- Author:
- Sam Brannen
- See Also:
-
Constructor Summary
ConstructorDescriptionSpringFailOnTimeout
(Statement next, long timeout) Construct a newSpringFailOnTimeout
statement for the suppliedtimeout
.SpringFailOnTimeout
(Statement next, Method testMethod) Construct a newSpringFailOnTimeout
statement for the suppliedtestMethod
, retrieving the configured timeout from the@Timed
annotation on the supplied method. -
Method Summary
Modifier and TypeMethodDescriptionvoid
evaluate()
Evaluate the nextstatement
in the execution chain (typically an instance ofSpringRepeat
) and throw aTimeoutException
if the nextstatement
executes longer than the specifiedtimeout
.
-
Constructor Details
-
SpringFailOnTimeout
Construct a newSpringFailOnTimeout
statement for the suppliedtestMethod
, retrieving the configured timeout from the@Timed
annotation on the supplied method.- Parameters:
next
- the nextStatement
in the execution chaintestMethod
- the current test method- See Also:
-
SpringFailOnTimeout
Construct a newSpringFailOnTimeout
statement for the suppliedtimeout
.If the supplied
timeout
is0
, the execution of thenext
statement will not be timed.- Parameters:
next
- the nextStatement
in the execution chain; nevernull
timeout
- the configuredtimeout
for the current test, in milliseconds; never negative
-
-
Method Details
-
evaluate
Evaluate the nextstatement
in the execution chain (typically an instance ofSpringRepeat
) and throw aTimeoutException
if the nextstatement
executes longer than the specifiedtimeout
.
-