Class FailOnTimeout.Builder
- java.lang.Object
-
- org.junit.internal.runners.statements.FailOnTimeout.Builder
-
- Enclosing class:
- FailOnTimeout
public static class FailOnTimeout.Builder extends java.lang.Object
Builder forFailOnTimeout
.- Since:
- 4.12
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
lookForStuckThread
private long
timeout
private java.util.concurrent.TimeUnit
unit
-
Constructor Summary
Constructors Modifier Constructor Description private
Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FailOnTimeout
build(Statement statement)
Builds aFailOnTimeout
instance using the values in this builder, wrapping the given statement.FailOnTimeout.Builder
withLookingForStuckThread(boolean enable)
Specifies whether to look for a stuck thread.FailOnTimeout.Builder
withTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Specifies the time to wait before timing out the test.
-
-
-
Method Detail
-
withTimeout
public FailOnTimeout.Builder withTimeout(long timeout, java.util.concurrent.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 returnedStatement
will wait forever for the test to complete, however the test 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 thetimeout
argument- Returns:
this
for method chaining.
-
withLookingForStuckThread
public FailOnTimeout.Builder withLookingForStuckThread(boolean enable)
Specifies whether to look for a stuck thread. If a timeout occurs and this feature is enabled, the test 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
-true
to enable the feature- Returns:
this
for method chaining.
-
build
public FailOnTimeout build(Statement statement)
Builds aFailOnTimeout
instance using the values in this builder, wrapping the given statement.- Parameters:
statement
-
-
-