Refine search
@Override public void evaluate() throws Throwable { List<Throwable> errors = new ArrayList<Throwable>(); startingQuietly(description, errors); try { base.evaluate(); succeededQuietly(description, errors); } catch (org.junit.internal.AssumptionViolatedException e) { errors.add(e); skippedQuietly(e, description, errors); } catch (Throwable e) { errors.add(e); failedQuietly(e, description, errors); } finally { finishedQuietly(description, errors); } MultipleFailureException.assertEmpty(errors); } };
@Override public void evaluate() throws Throwable { List<Throwable> errors = new ArrayList<Throwable>(); try { next.evaluate(); } catch (Throwable e) { errors.add(e); } try { app.stop(); } catch (Exception ex) { errors.add(ex); } if (errors.isEmpty()) { return; } if (errors.size() == 1) { throw errors.get(0); } throw new MultipleFailureException(errors); } };
base.evaluate(); if ( err instanceof MultipleFailureException ) failures.addAll( ( (MultipleFailureException) err ).getFailures() ); throw new MultipleFailureException( failures );
public static void throwAll(List<? extends Throwable> exceptions) throws Throwable { if (exceptions.isEmpty()) return; if (exceptions.size() == 1) throw exceptions.get(0); List<Throwable> unrolled = new ArrayList<>(); for (Throwable exception : exceptions) { if (exception instanceof MultipleFailureException) unrolled.addAll(((MultipleFailureException) exception).getFailures()); else unrolled.add(exception); } throw new MultipleFailureException(unrolled); } }
try base.evaluate(); for ( Throwable failure : multipleFailures.getFailures() )
@Override protected void verify() throws Throwable { MultipleFailureException.assertEmpty(errors); }
public void validateCollectedErrors() throws MultipleFailureException { if (errorCollectionEnabled){ if (!throwables.isEmpty()){ throw new MultipleFailureException(throwables); } } } }
private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
@Override public Object call() throws Exception { reportWriter.set(writer); try { base.evaluate(); } catch (MultipleFailureException e) { // Log the stack trace for each exception in the MultipleFailureException, because // stack traces won't be logged when this is caught and logged higher in the call stack. final List<Throwable> failures = e.getFailures(); log.error(format("MultipleFailureException contains %d failures:", failures.size())); for (int i = 0; i < failures.size(); i++) { log.error(format("MultipleFailureException %d:", i), failures.get(i)); } throw Throwables.propagate(e); } catch (Throwable throwable) { Throwables.propagateIfPossible(throwable, Exception.class); throw Throwables.propagate(throwable); } return null; } });
@Override protected void verify() throws Throwable { MultipleFailureException.assertEmpty(errors); }
private Exception createTimeoutException(Thread thread) { StackTraceElement[] stackTrace = thread.getStackTrace(); final Thread stuckThread = lookForStuckThread ? getStuckThread(thread) : null; Exception currThreadException = new TestTimedOutException(timeout, timeUnit); if (stackTrace != null) { currThreadException.setStackTrace(stackTrace); thread.interrupt(); } if (stuckThread != null) { Exception stuckThreadException = new Exception("Appears to be stuck in thread " + stuckThread.getName()); stuckThreadException.setStackTrace(getStackTrace(stuckThread)); return new MultipleFailureException( Arrays.<Throwable>asList(currThreadException, stuckThreadException)); } else { return currThreadException; } }
private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
/** * Evaluate the next {@link Statement} in the execution chain (typically an instance of * {@link org.junit.internal.runners.statements.RunAfters RunAfters}), catching any * exceptions thrown, and then invoke {@link TestContextManager#afterTestClass()}. * <p>If the invocation of {@code afterTestClass()} throws an exception, it will also * be tracked. Multiple exceptions will be combined into a {@link MultipleFailureException}. */ @Override public void evaluate() throws Throwable { List<Throwable> errors = new ArrayList<>(); try { this.next.evaluate(); } catch (Throwable ex) { errors.add(ex); } try { this.testContextManager.afterTestClass(); } catch (Throwable ex) { errors.add(ex); } MultipleFailureException.assertEmpty(errors); }
@Override public void evaluate() throws Throwable { List<Throwable> cumulative = new ArrayList<Throwable>(); try { beforeAfters.evaluate(); } catch (Throwable t) { cumulative.add(t); } // All @Afters must be called. for (Method m : afters) { try { invoke(m, instance); } catch (Throwable t) { cumulative.add(t); } } // At end, throw the exception or propagete. if (cumulative.size() == 1) { throw cumulative.get(0); } else if (cumulative.size() > 1) { throw new MultipleFailureException(cumulative); } } };
try base.evaluate(); for ( Throwable failure : multipleFailures.getFailures() )
private void completeThreads() throws Throwable { List<Throwable> failures = new ArrayList<>(); completeThreads( failures ); MultipleFailureException.assertEmpty( failures ); }
@Override public void intercept(IMethodInvocation invocation) throws Throwable { List<Throwable> throwableList = new ArrayList<>(); for (int i = 0; i <= retry.count(); i++) { Queue<Throwable> throwables = new ConcurrentLinkedQueue<>(); invocation.getFeature().getFeatureMethod().addInterceptor(new InnerRetryInterceptor(retry, condition, throwables)); invocation.proceed(); if (throwables.isEmpty()) { throwableList.clear(); break; } else { throwableList.addAll(throwables); if (retry.delay() > 0) Thread.sleep(retry.delay()); } } if (!throwableList.isEmpty()) { throw new MultipleFailureException(throwableList); } }
private void addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
/** * Evaluate the next {@link Statement} in the execution chain (typically an * instance of {@link RunBeforeTestExecutionCallbacks}), catching any exceptions * thrown, and then invoke {@link TestContextManager#afterTestExecution} supplying * the first caught exception (if any). * <p>If the invocation of {@code afterTestExecution()} throws an exception, that * exception will also be tracked. Multiple exceptions will be combined into a * {@link MultipleFailureException}. */ @Override public void evaluate() throws Throwable { Throwable testException = null; List<Throwable> errors = new ArrayList<>(); try { this.next.evaluate(); } catch (Throwable ex) { testException = ex; errors.add(ex); } try { this.testContextManager.afterTestExecution(this.testInstance, this.testMethod, testException); } catch (Throwable ex) { errors.add(ex); } MultipleFailureException.assertEmpty(errors); }
@Override public void evaluate() throws Throwable { MockitoAnnotations.initMocks(testClass); Throwable throwable = null; try { base.evaluate(); } catch (final Throwable t) { throwable = t; throw t; } finally { try { Mockito.validateMockitoUsage(); } catch (final Throwable t) { if (throwable != null) { throw new MultipleFailureException(Arrays.asList(new Throwable[]{throwable, t})); } else { throw t; } } } } };