程序包 org.junit.rules
类 Timeout.Builder
- java.lang.Object
- org.junit.rules.Timeout.Builder
- 封闭类:
- Timeout
public static class Timeout.Builder extends Object
Builder forTimeout
.- 从以下版本开始:
- 4.12
构造器概要
构造器 限定符 构造器 说明 protected
Builder()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 Timeout
build()
Builds aTimeout
instance using the values in this builderprotected boolean
getLookingForStuckThread()
protected long
getTimeout()
protected TimeUnit
getTimeUnit()
Timeout.Builder
withLookingForStuckThread(boolean enable)
Specifies whether to look for a stuck thread.Timeout.Builder
withTimeout(long timeout, TimeUnit unit)
Specifies the time to wait before timing out the test.
构造器详细资料
Builder
protected Builder()
方法详细资料
withTimeout
public Timeout.Builder withTimeout(long timeout, TimeUnit unit)
Specifies the time to wait before timing out the test.If this is not called, or is called with a
timeout
of0
, the returnedTimeout
rule instance will cause the tests to wait forever to complete, however the tests will still launch from a separate thread. This can be useful for disabling timeouts in environments where they are dynamically set based on some property.- 参数:
timeout
- the maximum time to waitunit
- the time unit of thetimeout
argument- 返回:
this
for method chaining.
getTimeout
protected long getTimeout()
getTimeUnit
protected TimeUnit getTimeUnit()
withLookingForStuckThread
public Timeout.Builder withLookingForStuckThread(boolean enable)
Specifies whether to look for a stuck thread. If a timeout occurs and this feature is enabled, the rule will look for a thread that appears to be stuck and dump its backtrace. This feature is experimental. Behavior may change after the 4.12 release in response to feedback.- 参数:
enable
-true
to enable the feature- 返回:
this
for method chaining.
getLookingForStuckThread
protected boolean getLookingForStuckThread()