/** * Creates a {@link Timeout} that will timeout a test after the * given duration, in milliseconds. * * @since 4.12 */ public static Timeout millis(long millis) { return new Timeout(millis, TimeUnit.MILLISECONDS); }
@Override public Statement apply( Statement base, Description description ) { // Just pick up on which test we're currently running currentTestDescription = description; return super.apply( base, description ); }
public Statement apply(Statement base, Description description) { try { return createFailOnTimeoutStatement(base); } catch (final Exception e) { return new Statement() { @Override public void evaluate() throws Throwable { throw new RuntimeException("Invalid parameters for Timeout", e); } }; } }
public static HBaseClassTestRule forClass(Class<?> clazz) { return new HBaseClassTestRule(clazz, Timeout.builder().withLookingForStuckThread(true) .withTimeout(getTimeoutInSeconds(clazz), TimeUnit.SECONDS).build()); }
public static TestRule getTimeoutRule(int timeout) { return IS_DEBUG ? new TestName() : Timeout.millis(timeout); }
public static TestRule getTimeoutRule(int timeout, TimeUnit unit) { return IS_DEBUG ? new TestName() : Timeout.builder().withTimeout(timeout, unit).build(); }
public Timeout getGlobalTimeoutValue() { return Timeout.millis(TypedProperties.getIntValue("globalTimeout")); }
/** * Creates a {@link Timeout} that will timeout a test after the * given duration, in seconds. * * @since 4.12 */ public static Timeout seconds(long seconds) { return new Timeout(seconds, TimeUnit.SECONDS); }
return Timeout.builder().withTimeout(waitLonger * defaultTimeoutSeconds(), TimeUnit.SECONDS) .withLookingForStuckThread(true).build();
@Override public Statement apply(Statement base, Description description) { return timeout.apply(base, description); } }
public Statement apply(Statement base, Description description) { try { return createFailOnTimeoutStatement(base); } catch (final Exception e) { return new Statement() { @Override public void evaluate() throws Throwable { throw new RuntimeException("Invalid parameters for Timeout", e); } }; } }
/** * Builds a {@link Timeout} instance using the values in this builder., */ public Timeout build() { return new Timeout(this); } }
public static TestRule timeoutRule(long timeout, TimeUnit timeUnit) { return new DisableOnDebug(Timeout.builder().withTimeout(timeout, timeUnit) .withLookingForStuckThread(true).build()); }
@Override public Statement apply(Statement base, Description description) { return timeout.apply(base, description); } }
public Statement apply(Statement base, Description description) { try { return createFailOnTimeoutStatement(base); } catch (final Exception e) { return new Statement() { @Override public void evaluate() throws Throwable { throw new RuntimeException("Invalid parameters for Timeout", e); } }; } }
/** * Creates the timeout rule that will be used to run the test. * * @return the rule used to check for test execution timeouts. */ protected TestRule createTestTimeoutRule() { int millisecondsTimeout = getTestTimeoutSecs() * 1000; if (isFailOnTimeout()) { return new DisableOnDebug(new Timeout(millisecondsTimeout)); } else { return new WarningTimeout(millisecondsTimeout); } }
/** * Creates a rule (chain) out of a gateway or other rule, adding extra rules as follows:<ol> * <li> a timeout rule * <li> a rule to print console messages at the start and end of each test method and print trace level * log messages on test failure. * </ol> * @param rule Rule to startup and stop gateway * @param timeout The maximum allowed time duration of each test (including the gateway rule) * @param timeUnit The unit for the timeout * @return A TestRule which should be the only public @Rule in our robot tests */ public static RuleChain createRuleChain(TestRule gateway, long timeout, TimeUnit timeUnit) { TestRule trace = new MethodExecutionTrace(); TestRule timeoutRule = new DisableOnDebug(Timeout.builder().withTimeout(timeout, timeUnit) .withLookingForStuckThread(true).build()); return RuleChain.outerRule(trace).around(timeoutRule).around(gateway); }
@Override public Statement apply(Statement base, Description description) { return timeout.apply(base, description); } }
/** * Creates a {@link Timeout} that will timeout a test after the * given duration, in milliseconds. * * @since 4.12 */ public static Timeout millis(long millis) { return new Timeout(millis, TimeUnit.MILLISECONDS); }