public Object run() throws Throwable { try { return runReflectiveCall(); } catch (InvocationTargetException e) { throw e.getTargetException(); } }
/** * Runs a {@link Statement} that represents a leaf (aka atomic) test. */ protected final void runLeaf(Statement statement, Description description, RunNotifier notifier) { EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description); eachNotifier.fireTestStarted(); try { statement.evaluate(); } catch (AssumptionViolatedException e) { eachNotifier.addFailedAssumption(e); } catch (Throwable e) { eachNotifier.addFailure(e); } finally { eachNotifier.fireTestFinished(); } }
private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
@Override public void run(final RunNotifier notifier) { EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription()); testNotifier.fireTestSuiteStarted(); try { Statement statement = classBlock(notifier); statement.evaluate(); } catch (AssumptionViolatedException e) { testNotifier.addFailedAssumption(e); } catch (StoppedByUserException e) { throw e; } catch (Throwable e) { testNotifier.addFailure(e); } finally { testNotifier.fireTestSuiteFinished(); } }
@Override public void run(final RunNotifier notifier) { EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription()); try { Statement statement = classBlock(notifier); statement.evaluate(); } catch (AssumptionViolatedException e) { testNotifier.fireTestIgnored(); } catch (StoppedByUserException e) { throw e; } catch (Throwable e) { testNotifier.addFailure(e); } }
@Override public void run(final RunNotifier notifier) { final Description description = getDescription(); final EachTestNotifier testNotifier = new EachTestNotifier(notifier, description); final Statement statement = classBlock(notifier); try { statement.evaluate(); } catch (AssumptionViolatedException e) { testNotifier.fireTestIgnored(); } catch (StoppedByUserException e) { // not retrying when user explicitly stops the test throw e; } catch (Throwable e) { // retry on any other exception retry(description, testNotifier, statement, e); } }
/** * Asserts that a list of throwables is empty. If it isn't empty, * will throw {@link MultipleFailureException} (if there are * multiple throwables in the list) or the first element in the list * (if there is only one element). * * @param errors list to check * @throws Throwable if the list is not empty */ @SuppressWarnings("deprecation") public static void assertEmpty(List<Throwable> errors) throws Throwable { if (errors.isEmpty()) { return; } if (errors.size() == 1) { throw errors.get(0); } /* * Many places in the code are documented to throw * org.junit.internal.runners.model.MultipleFailureException. * That class now extends this one, so we throw the internal * exception in case developers have tests that catch * MultipleFailureException. */ throw new org.junit.internal.runners.model.MultipleFailureException(errors); } }
public void addFailure(Throwable targetException) { if (targetException instanceof MultipleFailureException) { addMultipleFailureException((MultipleFailureException) targetException); } else { notifier.fireTestFailure(new Failure(description, targetException)); } }
for(final Throwable failure : ((MultipleFailureException)t).getFailures()){ final boolean isMissingCreds = isMissingCredsException( failure );
/** * Runs a {@link Statement} that represents a leaf (aka atomic) test. */ protected final void runLeaf(Statement statement, Description description, RunNotifier notifier) { EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description); eachNotifier.fireTestStarted(); try { statement.evaluate(); } catch (AssumptionViolatedException e) { eachNotifier.addFailedAssumption(e); } catch (Throwable e) { eachNotifier.addFailure(e); } finally { eachNotifier.fireTestFinished(); } }
private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
/** * Asserts that a list of throwables is empty. If it isn't empty, * will throw {@link MultipleFailureException} (if there are * multiple throwables in the list) or the first element in the list * (if there is only one element). * * @param errors list to check * @throws Exception or Error if the list is not empty */ @SuppressWarnings("deprecation") public static void assertEmpty(List<Throwable> errors) throws Exception { if (errors.isEmpty()) { return; } if (errors.size() == 1) { throw Throwables.rethrowAsException(errors.get(0)); } /* * Many places in the code are documented to throw * org.junit.internal.runners.model.MultipleFailureException. * That class now extends this one, so we throw the internal * exception in case developers have tests that catch * MultipleFailureException. */ throw new org.junit.internal.runners.model.MultipleFailureException(errors); } }
public Object run() throws Throwable { try { return runReflectiveCall(); } catch (InvocationTargetException e) { throw e.getTargetException(); } }
public void addFailure(Throwable targetException) { if (targetException instanceof MultipleFailureException) { addMultipleFailureException((MultipleFailureException) targetException); } else { fNotifier .fireTestFailure(new Failure(fDescription, targetException)); } }
private void runTestUnit(final Statement statement, final Description description, final RunNotifier notifier) { final EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description); eachNotifier.fireTestStarted(); try { statement.evaluate(); } catch (AssumptionViolatedException e) { eachNotifier.addFailedAssumption(e); } catch (Throwable e) { retry(description, eachNotifier, statement, e); } finally { eachNotifier.fireTestFinished(); } }
private void retry(final Description description, final EachTestNotifier notifier, final Statement statement, final Throwable currentThrowable) { Throwable caughtThrowable = currentThrowable; while (retryCount > failedAttempts) { try { System.out.println(description + " Caught: " + (currentThrowable == null ? "exception" : currentThrowable.getMessage()) + ". Retrying test " + failedAttempts + "/" + retryCount); statement.evaluate(); return; } catch (Throwable t) { failedAttempts++; caughtThrowable = t; } } notifier.addFailure(caughtThrowable); } }
public Object run() throws Throwable { try { return runReflectiveCall(); } catch (InvocationTargetException e) { throw e.getTargetException(); } }
public void addFailure(Throwable targetException) { if (targetException instanceof MultipleFailureException) { addMultipleFailureException((MultipleFailureException) targetException); } else { fNotifier .fireTestFailure(new Failure(fDescription, targetException)); } }
@Override protected void runChild(JSONObject child, RunNotifier notifier) { EachTestNotifier eachNotifier = new EachTestNotifier(notifier, describeChild(child)); eachNotifier.fireTestStarted(); try { new TestCaseRunner(child).run(); eachNotifier.fireTestFinished(); } catch (Exception | AssertionError e) { eachNotifier.addFailure(e); } }
private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }