Refine search
/** * 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(); } }
@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) { 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) { 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); } }
@Override public void run(final RunNotifier notifier) { EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription()); try { Statement statement = classBlock(notifier); statement.evaluate(); } catch (AssumptionViolatedException e) { testNotifier.addFailedAssumption(e); } catch (StoppedByUserException e) { throw e; } catch (Throwable e) { testNotifier.addFailure(e); } }
/** * Runs a {@link Statement} that represents a leaf (aka atomic) test. */ protected final void runTestMethod(FrameworkMethod method, EachTestNotifier notifier, int retriesLeft) { Statement statement = methodBlock(method); try { statement.evaluate(); } catch (AssumptionViolatedException e) { notifier.addFailedAssumption(e); } catch (TimeoutException e) { /* TimeoutException thrown by ThrowOnTimeout statement. Handling is kept in this class since this is where the retry needs to be triggered in order to get the right tear down and test setup between retries. */ if (--retriesLeft >= 0) { LOGGER.warn( "Test case timed out. Will attempt retry {} more times. Turn on log level DEBUG for stacktrace", retriesLeft); LOGGER.debug(e.getMessage(), e); tearDown(); runTestMethod(method, notifier, retriesLeft); } else { notifier.addFailure(e); } } catch (Throwable e) { notifier.addFailure(e); } }
//Get each test notifier EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription()); try { //In order capture testRunStarted method //at the very beginning of the test run, we will add below code. //Invoke here the run testRunStarted() method notifier.fireTestRunStarted(getDescription()); Statement statement = classBlock(notifier); statement.evaluate(); } catch (AssumptionViolatedException e) { testNotifier.fireTestIgnored(); } catch (StoppedByUserException e) { throw e; } catch (Throwable e) { testNotifier.addFailure(e); }
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 void execute(final Statement statement, final RunNotifier notifier, final Description description) { final EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description); try { beforeExecution(eachNotifier); statement.evaluate(); } catch (final InitializationError e) { whenInitializationErrorIsRaised(eachNotifier, e); } catch (final AssumptionViolatedException e) { whenAssumptionViolatedExceptionIsRaised(eachNotifier, e); } catch (final Throwable e) { whenThrowableIsRaised(eachNotifier, e); } finally { afterExecution(eachNotifier); } }
@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 addMultipleFailureException(MultipleFailureException mfe) { for (Throwable each : mfe.getFailures()) { addFailure(each); } }
private void addFailureOrIgnoreStep(Result result) { if (strict) { stepNotifier.fireTestStarted(); addFailure(result); stepNotifier.fireTestFinished(); } else { ignoredStep = true; stepNotifier.fireTestIgnored(); } }
private EachTestNotifier makeNotifier(FrameworkMethod method, RunNotifier notifier) { Description description = describeChild(method); return new EachTestNotifier(notifier, description); } }
@Override public void run(RunNotifier notifier) { Description childDescription = Description.createTestDescription(getClass(), "Test"); desc.addChild(childDescription); EachTestNotifier singleNotifier = new EachTestNotifier(notifier, childDescription); singleNotifier.addFailedAssumption(new AssumptionViolatedException("Test 2")); singleNotifier.addFailedAssumption(new AssumptionViolatedException("Test 1")); singleNotifier.addFailure(new IllegalArgumentException("Test")); } };
public void startExecutionUnit(ExecutionUnitRunner executionUnitRunner, RunNotifier runNotifier) { this.executionUnitRunner = executionUnitRunner; this.runNotifier = runNotifier; this.stepNotifier = null; this.failedStep = false; this.ignoredStep = false; executionUnitNotifier = new EachTestNotifier(runNotifier, executionUnitRunner.getDescription()); executionUnitNotifier.fireTestStarted(); // PageRecorder.showMessage(executionUnitRunner.getDescription().getDisplayName(), // "info"); }
@Override public void run(final RunNotifier notifier) { EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription()); try { String[] packageParts = getTestClass().getJavaClass().getPackage().getName().split("\\."); if(null == packageParts || packageParts.length < 1 || !packageParts[0].equals("it")) { throw new Exception("the class [" + getTestClass().getJavaClass().getName() + "] is annotated with @RunWith(AtlassianPluginsTestRunner.class) but it is not in the 'it.' package." + "\nPlease move the class into the 'it.' package or remove the @RunWith annotation"); } runViaRestCall(getDescription(), notifier); } catch (AssumptionViolatedException e) { testNotifier.fireTestIgnored(); } catch (StoppedByUserException e) { throw e; } catch (Throwable e) { testNotifier.addFailure(e); } }
public void finishExecutionUnit() { if (ignoredStep && !failedStep) { executionUnitNotifier.fireTestIgnored(); } executionUnitNotifier.fireTestFinished(); }
@Override public void run(final RunNotifier notifier) { super.run(notifier); if (instanceSetupListener != null) { try { instanceSetupListener.runAfterAllTests(); } catch (final AssumptionViolatedException e) { new EachTestNotifier(notifier, getDescription()).fireTestIgnored(); } catch (final Exception e) { throw new IllegalStateException(e); } } } }
private void runIgnored(EachTestNotifier eachNotifier) { eachNotifier.fireTestIgnored(); }
@Override protected void afterExecution(final EachTestNotifier notifier) { notifier.fireTestFinished(); } }