Package org.junit.rules
Class Timeout.Builder
java.lang.Object
org.junit.rules.Timeout.Builder
- Enclosing class:
Timeout
Builder for
Timeout.- Since:
- 4.12
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds aTimeoutinstance using the values in this builder.,protected booleanprotected longprotected TimeUnitwithLookingForStuckThread(boolean enable) Specifies whether to look for a stuck thread.withTimeout(long timeout, TimeUnit unit) Specifies the time to wait before timing out the test.
-
Field Details
-
lookForStuckThread
private boolean lookForStuckThread -
timeout
private long timeout -
timeUnit
-
-
Constructor Details
-
Builder
protected Builder()
-
-
Method Details
-
withTimeout
Specifies the time to wait before timing out the test.If this is not called, or is called with a
timeoutof0, the returnedTimeoutrule 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.- Parameters:
timeout- the maximum time to waitunit- the time unit of thetimeoutargument- Returns:
thisfor method chaining.
-
getTimeout
protected long getTimeout() -
getTimeUnit
-
withLookingForStuckThread
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.- Parameters:
enable-trueto enable the feature- Returns:
thisfor method chaining.
-
getLookingForStuckThread
protected boolean getLookingForStuckThread() -
build
Builds aTimeoutinstance using the values in this builder.,
-