public void retry( EachTestNotifier notifier, Statement statement, Throwable currentThrowable ) { Throwable caughtThrowable = currentThrowable; while ( retryCount > failedAttempts ) { try { timeout( failedAttempts + 1 ); statement.evaluate(); return; } catch ( Throwable t ) { failedAttempts++; caughtThrowable = t; } } notifier.addFailure( caughtThrowable ); }
@Override public void runChild(final FrameworkMethod method, final RunNotifier notifier) { final Description description = describeChild(method); if (this.isIgnored(method)) { notifier.fireTestIgnored(description); } else { EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description); eachNotifier.fireTestStarted(); boolean ignored = false; try { this.methodBlock(method).evaluate(); } catch (AssumptionViolatedException ave) { eachNotifier.addFailedAssumption(ave); } catch (Throwable e) { if (validateForGraphComputer(e)) { eachNotifier.fireTestIgnored(); logger.info(e.getMessage()); ignored = true; } else eachNotifier.addFailure(e); } finally { if (!ignored) eachNotifier.fireTestFinished(); } } }
@Override protected void runChild(FrameworkMethod method, RunNotifier notifier) { EachTestNotifier eachNotifier = makeNotifier( method, notifier ); FuzzUnitTestMethod tTestMethod = (FuzzUnitTestMethod) method; eachNotifier.fireTestStarted(); if( method.getAnnotation( Ignore.class ) != null ) { eachNotifier.fireTestIgnored(); return; } try { methodBlock( tTestMethod ).evaluate(); } catch (Throwable e) { eachNotifier.addFailure( e ); } finally { eachNotifier.fireTestFinished(); } }
private void endTracing(FrameworkMethod method, RunNotifier notifier) { if (shouldCreateNewTraceObject(method)) { TraceContext traceContext = this.testAgent.getTraceContext(); try { Trace trace = traceContext.currentRawTraceObject(); if (trace == null) { // Trace is already detached from the ThreadLocal storage. // Happens when root trace method is tested without @IsRootSpan. EachTestNotifier testMethodNotifier = new EachTestNotifier(notifier, super.describeChild(method)); String traceObjectAlreadyDetachedMessage = "Trace object already detached. If you're testing a trace root, please add @IsRootSpan to the test method"; testMethodNotifier.addFailure(new IllegalStateException(traceObjectAlreadyDetachedMessage)); } else { try { trace.markAfterTime(); } finally { trace.traceRootBlockEnd(); } } } finally { traceContext.detachTraceObject(); } } }
private void endTracing(FrameworkMethod method, RunNotifier notifier) { if (shouldCreateNewTraceObject(method)) { TraceContext traceContext = getTraceContext(); try { Trace trace = traceContext.currentRawTraceObject(); if (trace == null) { // Trace is already detached from the ThreadLocal storage. // Happens when root trace method is tested without @IsRootSpan. EachTestNotifier testMethodNotifier = new EachTestNotifier(notifier, super.describeChild(method)); String traceObjectAlreadyDetachedMessage = "Trace object already detached. If you're testing a trace root, please add @IsRootSpan to the test method"; testMethodNotifier.addFailure(new IllegalStateException(traceObjectAlreadyDetachedMessage)); } else { trace.close(); } } finally { traceContext.removeTraceObject(); } } }
@Override protected void runChild(final FrameworkMethod method, RunNotifier notifier) { Description description = describeChild(method); if (method.getAnnotation(Ignore.class) != null) { notifier.fireTestIgnored(description); } else { setLogContext(method); EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description); eachNotifier.fireTestStarted(); try { runTestMethod(method, eachNotifier, config.getTimeoutRetries()); } finally { eachNotifier.fireTestFinished(); clearLogContext(); } } }
private void invokeTest(RunNotifier notifier, TestExecutorType type, FrameworkMethod method) { if ((type == null) || TestExecutorType.LOCAL.equals(type)) { runLeaf(methodBlock(method), describeChild(method), notifier); } else { EachTestNotifier eachNotifier = new EachTestNotifier(notifier, describeChild(method)); try { eachNotifier.fireTestStarted(); execute(type, method.getMethod()).get(); } catch (Throwable e) { eachNotifier.addFailure(e); } finally { eachNotifier.fireTestFinished(); } } }
private void runLeafAndIgnoreErrors(Statement statement, Description description, RunNotifier notifier) { EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description); eachNotifier.fireTestStarted(); try { statement.evaluate(); } catch (Throwable e) { // An error ? Surely you must be joking } finally { eachNotifier.fireTestFinished(); } }
public void retry(EachTestNotifier notifier, Statement statement, Throwable currentThrowable) { Throwable caughtThrowable = currentThrowable; while (RETRY_COUNT > failedAttempts) { try { statement.evaluate(); return; } catch (Throwable t) { failedAttempts++; caughtThrowable = t; } } notifier.addFailure(caughtThrowable); }
@Override protected void runChild(Test child, RunNotifier notifier) { Description description = describeChild(child); EachTestNotifier eachTestNotifier = new EachTestNotifier( notifier, description); eachTestNotifier.fireTestStarted(); try { child.statement.evaluate(); } catch (Throwable t) { eachTestNotifier.addFailure(t); } finally { eachTestNotifier.fireTestFinished(); } }
/** * Sets that tests are failed. * * @param notifier * Notifier that should be notified */ protected void setTestsToFail(final RunNotifier notifier) { final Description description = getDescription(); final ArrayList<Description> toBeFailed = new ArrayList<>(description.getChildren()); // all testmethods will be covered and set to failed here toBeFailed.add(description); // the whole test class failed for (final Description d : toBeFailed) { final EachTestNotifier testNotifier = new EachTestNotifier(notifier, d); testNotifier.addFailure(new TimeoutException("Test timed out because of class timeout")); } }
private EachTestNotifier makeNotifier(FrameworkMethod method, RunNotifier notifier) { Description description = describeChild(method); return new EachTestNotifier(notifier, description); }
protected EachTestNotifier makeNotifier(FrameworkMethod method, RunNotifier notifier) { Description description= describeChild(method); return new EachTestNotifier(notifier, description); }
@Override protected void beforeExecution(final EachTestNotifier notifier) { notifier.fireTestStarted(); }
@Override protected void afterExecution(final EachTestNotifier notifier) { notifier.fireTestFinished(); }
/** * Creates a notifier for each test. * * @param method * the {@link FrameworkMethod}, must not be {@code null} * @param notifier * the {@link RunNotifier}, must not be {@code null} * @return an instance of {@link EachTestNotifier}, never {@code null} */ private EachTestNotifier createNotifier(final FrameworkMethod method, final RunNotifier notifier) { return new EachTestNotifier(notifier, describeChild(method)); }
/** * @param method the test * @param notifier a test run notifier * @return the married test and notifier */ protected EachTestNotifier makeNotifier( FrameworkMethod method, RunNotifier notifier ) { return new EachTestNotifier( notifier, describeChild( method ) ); }
/** * {@code springMakeNotifier()} is an exact copy of * {@link BlockJUnit4ClassRunner BlockJUnit4ClassRunner's} * {@code makeNotifier()} method, but we have decided to prefix it with * "spring" and keep it {@code private} in order to avoid the * compatibility clashes that were introduced in JUnit between versions 4.5, * 4.6, and 4.7. */ private EachTestNotifier springMakeNotifier(FrameworkMethod method, RunNotifier notifier) { Description description = describeChild(method); return new EachTestNotifier(notifier, description); }
/** * Clients may override this method to add additional behavior prior to the execution of the statement. * The call of this method is guaranteed. * * @param notifier the notifier */ protected void beforeExecution(final EachTestNotifier notifier) { }
/** * Clients may override this method to add additional behavior when a {@link InitializationError} is raised. * The call of this method is guaranteed. * * @param notifier the notifier * @param e the error */ protected void whenInitializationErrorIsRaised(final EachTestNotifier notifier, final InitializationError e) { notifier.addFailure(new MultipleFailureException(e.getCauses())); }
/** * Clients may override this method to add additional behavior when a {@link AssumptionViolatedException} is raised. * The call of this method is guaranteed. * * @param notifier the notifier * @param e the error */ protected void whenAssumptionViolatedExceptionIsRaised(final EachTestNotifier notifier, final AssumptionViolatedException e) { notifier.addFailedAssumption(e); }
/** * Clients may override this method to add additional behavior when a {@link Throwable} is raised. * * @param notifier the notifier * @param e the error */ protected void whenThrowableIsRaised(final EachTestNotifier notifier, final Throwable e) { notifier.addFailure(e); }
/** * Clients may override this method to add additional behavior after the execution of the statement. * The call of this method is guaranteed. * * @param notifier the notifier */ protected void afterExecution(final EachTestNotifier notifier) { }