Home | History | Annotate | Download | only in rules

Lines Matching refs:timeout

10  * The Timeout Rule applies the same timeout to all test methods in a class:
15 * public Timeout globalTimeout= new Timeout(20);
29 * Each test is run in a new thread. If the specified timeout elapses before
34 * A specified timeout of 0 will be interpreted as not set, however tests will
40 public class Timeout implements TestRule {
41 private final long timeout;
54 * Create a {@code Timeout} instance with the timeout specified
59 * Instead use {@link #Timeout(long, java.util.concurrent.TimeUnit)},
60 * {@link Timeout#millis(long)}, or {@link Timeout#seconds(long)}.
63 * test to run before it should timeout
66 public Timeout(int millis) {
71 * Create a {@code Timeout} instance with the timeout specified
74 * @param timeout the maximum time to allow the test to run
75 * before it should timeout
76 * @param timeUnit the time unit for the {@code timeout}
79 public Timeout(long timeout, TimeUnit timeUnit) {
80 this.timeout = timeout;
85 * Create a {@code Timeout} instance initialized with values form
90 protected Timeout(Builder builder) {
91 timeout = builder.getTimeout();
96 * Creates a {@link Timeout} that will timeout a test after the
101 public static Timeout millis(long millis) {
102 return new Timeout(millis, TimeUnit.MILLISECONDS);
106 * Creates a {@link Timeout} that will timeout a test after the
111 public static Timeout seconds(long seconds) {
112 return new Timeout(seconds, TimeUnit.SECONDS);
116 * Gets the timeout configured for this rule, in the given units.
121 return unit.convert(timeout, timeUnit);
126 * {@code statement}, and timeout the operation based
135 .withTimeout(timeout, timeUnit)
145 throw new RuntimeException("Invalid parameters for Timeout", e);
152 * Builder for {@link Timeout}.
158 private long timeout = 0;
168 * {@code timeout} of {@code 0}, the returned {@code Timeout}
175 * @param timeout the maximum time to wait
176 * @param unit the time unit of the {@code timeout} argument
179 public Builder withTimeout(long timeout, TimeUnit unit) {
180 this.timeout = timeout;
186 return timeout;
194 * Builds a {@link Timeout} instance using the values in this builder.,
196 public Timeout build() {
197 return new Timeout(this);