private void closeRunNotifier( org.junit.runner.notification.RunListener main, List<org.junit.runner.notification.RunListener> others) { RunNotifier fNotifier = new RunNotifier(); fNotifier.removeListener(main); for (org.junit.runner.notification.RunListener listener : others) { fNotifier.removeListener(listener); } }
@Override public void run(RunNotifier notifier) { RunListener failureSpy = new ScreenshotCaptureListener(); notifier.removeListener(failureSpy); notifier.addListener(failureSpy); try { super.run(notifier); } finally { notifier.removeListener(failureSpy); } }
@Override public void evaluate() throws Throwable { Error error = error(); notifier.addListener(listener); try { log.debug(displayName(description) + " STARTED"); for (int retry = 1; retry <= retryCount(); retry++) { gotFailure = false; onEnter(retry); try { log.debug(displayName(description) + " retry " + retry); base.evaluate(); } catch (AssumptionViolatedException cause) { Throwable t = new Throwable("On retry " + retry).initCause(cause); error.addSuppressed(t); notifier.fireTestAssumptionFailed(new Failure(description, t)); } catch (Throwable cause) { // Repeat annotation is on method (else the Throwable is not raised up to here) Throwable t = new Throwable("On retry " + retry).initCause(cause); error.addSuppressed(t); if (returnOnFailure()) { notifier.fireTestFailure(new Failure(description, t)); } else { gotFailure = true; log.debug(displayName(description) + " FAILURE SWALLOW"); log.trace(t, t); } } finally { onLeave(); } if (gotFailure && returnOnFailure()) { log.debug(displayName(description) + " returnOnFailure"); return; } if (!gotFailure && returnOnSuccess()) { log.debug(displayName(description) + " returnOnSuccess"); return; } } } finally { log.debug(displayName(description) + " FINISHED"); notifier.removeListener(listener); } log.trace("throw " + error); throw error; }
/** * Remove a listener. * * @param listener the listener to remove */ public void removeListener(RunListener listener) { fNotifier.removeListener(listener); }