/** * If called with an expression evaluating to {@code false}, the test will halt and be ignored. * * @param b If <code>false</code>, the method will attempt to stop the test and ignore it by * throwing {@link AssumptionViolatedException}. * @param message A message to pass to {@link AssumptionViolatedException}. */ public static void assumeTrue(String message, boolean b) { if (!b) throw new AssumptionViolatedException(message); }
/** * An assumption exception with the given message and a cause. * * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead. */ @Deprecated public AssumptionViolatedException(String assumption, Throwable e) { this(assumption, false, null, null); initCause(e); }
if (isSupported(IS_BLOBSTORE)) { throw new AssumptionViolatedException(failure.toString()).initCause(failure);
s.evaluate(); } catch (AssumptionViolatedException ex) { if (!ex.getMessage().equals("LoggerRule can't capture logs for LoggerAdapter")) { throw ex;
if (isSupported(IS_BLOBSTORE)) { throw new AssumptionViolatedException(failure.toString()).initCause(failure);
@Override public void evaluate() throws Throwable { try { statement.evaluate(); } catch (AssumptionViolatedException e) { StepEventBus.getEventBus().assumptionViolated(e.getMessage()); } checkForStepFailures(); checkForAssumptionViolations(); }
/** * Call to assume that <code>actual</code> satisfies the condition specified by <code>matcher</code>. * If not, the test halts and is ignored. * Example: * <pre>: * assumeThat(1, is(1)); // passes * foo(); // will execute * assumeThat(0, is(1)); // assumption failure! test halts * int x = 1 / 0; // will never execute * </pre> * * @param <T> the static type accepted by the matcher (this can flag obvious compile-time problems such as {@code assumeThat(1, is("a"))} * @param actual the computed value being compared * @param matcher an expression, built of {@link Matcher}s, specifying allowed values * @see org.hamcrest.CoreMatchers * @see org.junit.matchers.JUnitMatchers */ public static <T> void assumeThat(T actual, Matcher<T> matcher) { if (!matcher.matches(actual)) { throw new AssumptionViolatedException(actual, matcher); } }
private Object executeTestStepMethod(Object obj, Method method, Object[] args, MethodProxy proxy, Object result) throws Throwable { try { result = invokeMethod(obj, args, proxy); notifyStepFinishedFor(method, args); } catch (PendingStepException pendingStep) { notifyStepPending(pendingStep.getMessage()); } catch (IgnoredStepException ignoredStep) { notifyStepIgnored(ignoredStep.getMessage()); } catch (AssumptionViolatedException assumptionViolated) { notifyAssumptionViolated(assumptionViolated.getMessage()); } Preconditions.checkArgument(true); return result; }
/** * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead. */ @Deprecated public AssumptionViolatedException(String assumption, boolean hasValue, Object value, Matcher<?> matcher) { this.fAssumption = assumption; this.fValue = value; this.fMatcher = matcher; this.fValueMatcher = hasValue; if (value instanceof Throwable) { initCause((Throwable) value); } }
/** * Call to assume that <code>actual</code> satisfies the condition specified by <code>matcher</code>. * If not, the test halts and is ignored. * Example: * <pre>: * assumeThat(1, is(1)); // passes * foo(); // will execute * assumeThat(0, is(1)); // assumption failure! test halts * int x = 1 / 0; // will never execute * </pre> * * @param <T> the static type accepted by the matcher (this can flag obvious compile-time problems such as {@code assumeThat(1, is("a"))} * @param actual the computed value being compared * @param matcher an expression, built of {@link Matcher}s, specifying allowed values * @see org.hamcrest.CoreMatchers * @see org.junit.matchers.JUnitMatchers */ public static <T> void assumeThat(String message, T actual, Matcher<T> matcher) { if (!matcher.matches(actual)) { throw new AssumptionViolatedException(message, actual, matcher); } }
private Object executeTestStepMethod(Object obj, Method method, Object[] args, MethodProxy proxy, Object result) throws Throwable { try { result = invokeMethod(obj, args, proxy); notifyStepFinishedFor(method, args); } catch(PendingStepException pendingStep) { notifyStepPending(pendingStep.getMessage()); } catch(IgnoredStepException ignoredStep) { notifyStepIgnored(ignoredStep.getMessage()); } catch(AssumptionViolatedException assumptionViolated) { notifyAssumptionViolated(assumptionViolated.getMessage()); } Preconditions.checkArgument(true); return result; }
/** * An assumption exception with the given message and a cause. * * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead. */ @Deprecated public AssumptionViolatedException(String assumption, Throwable e) { this(assumption, false, null, null); initCause(e); }
private void verify(SentinelsAvailable verificationMode) { int failed = 0; for (RedisNode node : sentinelConfig.getSentinels()) { if (!isAvailable(node)) { failed++; } } if (failed > 0) { if (SentinelsAvailable.ALL_ACTIVE.equals(verificationMode)) { throw new AssumptionViolatedException( String.format("Expected all Redis Sentinels to respone but %s of %s did not responde", failed, sentinelConfig.getSentinels().size())); } if (SentinelsAvailable.ONE_ACTIVE.equals(verificationMode) && sentinelConfig.getSentinels().size() - 1 < failed) { throw new AssumptionViolatedException( "Expected at least one sentinel to respond but it seems all are offline - Game Over!"); } } if (SentinelsAvailable.NONE_ACTIVE.equals(verificationMode) && failed != sentinelConfig.getSentinels().size()) { throw new AssumptionViolatedException( String.format("Expected to have no sentinels online but found that %s are still alive.", (sentinelConfig.getSentinels().size() - failed))); } }
private Object executeTestStepMethod(Object obj, Method method, Object[] args, MethodProxy proxy, Object result) throws Throwable { try { result = invokeMethod(obj, args, proxy); notifyStepFinishedFor(method, args); } catch(PendingStepException pendingStep) { notifyStepPending(pendingStep.getMessage()); } catch(IgnoredStepException ignoredStep) { notifyStepIgnored(ignoredStep.getMessage()); } catch(AssumptionViolatedException assumptionViolated) { notifyAssumptionViolated(assumptionViolated.getMessage()); } Preconditions.checkArgument(true); return result; }
/** * An assumption exception with the given message and a cause. * * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead. */ @Deprecated public AssumptionViolatedException(String assumption, Throwable e) { this(assumption, false, null, null); initCause(e); }
/** * If called with an expression evaluating to {@code false}, the test will halt and be ignored. * * @param b If <code>false</code>, the method will attempt to stop the test and ignore it by * throwing {@link AssumptionViolatedException}. * @param message A message to pass to {@link AssumptionViolatedException}. */ public static void assumeTrue(String message, boolean b) { if (!b) throw new AssumptionViolatedException(message); }
if (ex.getMessage() != null) { log.warn("{} threw AssumptionViolatedException - skipping test execution due to {}", getName(), ex.getMessage()); } else { log.warn("{} threw AssumptionViolatedException - skipping test execution. No reason given.", getName());
/** * @deprecated Please use {@link org.junit.AssumptionViolatedException} instead. */ @Deprecated public AssumptionViolatedException(String assumption, boolean hasValue, Object value, Matcher<?> matcher) { this.fAssumption = assumption; this.fValue = value; this.fMatcher = matcher; this.fValueMatcher = hasValue; if (value instanceof Throwable) { initCause((Throwable) value); } }
/** * Call to assume that <code>actual</code> satisfies the condition specified by <code>matcher</code>. * If not, the test halts and is ignored. * Example: * <pre>: * assumeThat(1, is(1)); // passes * foo(); // will execute * assumeThat(0, is(1)); // assumption failure! test halts * int x = 1 / 0; // will never execute * </pre> * * @param <T> the static type accepted by the matcher (this can flag obvious compile-time problems such as {@code assumeThat(1, is("a"))} * @param actual the computed value being compared * @param matcher an expression, built of {@link Matcher}s, specifying allowed values * @see org.hamcrest.CoreMatchers * @see org.junit.matchers.JUnitMatchers */ public static <T> void assumeThat(T actual, Matcher<T> matcher) { if (!matcher.matches(actual)) { throw new AssumptionViolatedException(actual, matcher); } }
@Override public void evaluate() throws Throwable { logger.info("{} starting...", testName(method)); try { base.evaluate(); logger.debug("{} SUCCESS", testName(method)); } catch (AssumptionViolatedException e) { logger.info("{} Ignored: {}", testName(method), e.getMessage()); throw e; } catch (Throwable t) { logger.warn("{} FAILED: {}", testName(method), t.getMessage()); throw t; } } };