类 SpringFailOnTimeout
- java.lang.Object
- org.junit.runners.model.Statement
- org.springframework.test.context.junit4.statements.SpringFailOnTimeout
public class SpringFailOnTimeout extends Statement
SpringFailOnTimeout
is a custom JUnitStatement
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 nextstatement
will be executed in the same thread as the caller and will therefore not be aborted preemptively.- 从以下版本开始:
- 3.0
- 作者:
- Sam Brannen
- 另请参阅:
evaluate()
构造器概要
构造器 构造器 说明 SpringFailOnTimeout(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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
evaluate()
Evaluate the nextstatement
in the execution chain (typically an instance ofSpringRepeat
) and throw aTimeoutException
if the nextstatement
executes longer than the specifiedtimeout
.
构造器详细资料
SpringFailOnTimeout
public SpringFailOnTimeout(Statement next, Method testMethod)
Construct a newSpringFailOnTimeout
statement for the suppliedtestMethod
, retrieving the configured timeout from the@Timed
annotation on the supplied method.- 参数:
next
- the nextStatement
in the execution chaintestMethod
- the current test method- 另请参阅:
TestAnnotationUtils.getTimeout(Method)
SpringFailOnTimeout
public SpringFailOnTimeout(Statement next, long timeout)
Construct a newSpringFailOnTimeout
statement for the suppliedtimeout
.If the supplied
timeout
is0
, the execution of thenext
statement will not be timed.- 参数:
next
- the nextStatement
in the execution chain; nevernull
timeout
- the configuredtimeout
for the current test, in milliseconds; never negative
方法详细资料
evaluate
public void evaluate() throws Throwable
Evaluate the nextstatement
in the execution chain (typically an instance ofSpringRepeat
) and throw aTimeoutException
if the nextstatement
executes longer than the specifiedtimeout
.