use of org.junit.internal.runners.model.EachTestNotifier in project java-sdk by watson-developer-cloud.
the class RetryRunner method run.
/*
* (non-Javadoc)
*
* @see org.junit.runners.ParentRunner#run(org.junit.runner.notification.RunNotifier)
*/
@Override
public void run(final RunNotifier notifier) {
EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription());
Statement statement = classBlock(notifier);
try {
statement.evaluate();
} catch (AssumptionViolatedException ave) {
testNotifier.fireTestIgnored();
} catch (StoppedByUserException sbue) {
throw sbue;
} catch (Throwable t) {
LOG.warning("Retry class: " + getDescription().getDisplayName());
retry(testNotifier, statement, t, getDescription());
}
}
use of org.junit.internal.runners.model.EachTestNotifier in project junit4 by junit-team.
the class ParentRunner method runLeaf.
/**
* 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();
}
}
use of org.junit.internal.runners.model.EachTestNotifier in project junit4 by junit-team.
the class ParentRunner method run.
@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();
}
}
use of org.junit.internal.runners.model.EachTestNotifier in project hive by apache.
the class RetryTestRunner method run.
// from ParentRunner, retried under exception (notified only after exhausting retryCount)
// invoked for test classes
@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);
}
}
use of org.junit.internal.runners.model.EachTestNotifier in project blueocean-plugin by jenkinsci.
the class ATHJUnitRunner method runTest.
private void runTest(Statement statement, Description description, RunNotifier notifier, Retry retry) {
logger.info(String.format("Running test: '%s'", description.getMethodName()));
String buildName = System.getenv("BUILD_TAG");
if (StringUtils.isEmpty(buildName)) {
buildName = System.getenv("BUILD_TAG");
}
// https://wiki.saucelabs.com/display/DOCS/Annotating+Tests+with+Selenium%27s+JavaScript+Executor
if (StringUtils.isNotEmpty(buildName)) {
LocalDriver.executeSauce(String.format("job-build=%s", buildName));
}
LocalDriver.executeSauce(String.format("job-name=%s", description.getMethodName()));
EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
eachNotifier.fireTestStarted();
List<Throwable> failures = new ArrayList<>();
try {
int n = retry == null ? 1 : retry.value();
for (int i = 0; i < n; i++) {
try {
statement.evaluate();
failures.clear();
break;
} catch (AssumptionViolatedException e) {
throw e;
} catch (Throwable e) {
if (n <= 1) {
failures.add(e);
} else {
failures.add(new RetryThrowable(i, e));
}
}
}
for (Throwable failure : failures) {
eachNotifier.addFailure(failure);
}
} catch (AssumptionViolatedException e) {
eachNotifier.addFailedAssumption(e);
} catch (Throwable e) {
eachNotifier.addFailure(e);
} finally {
eachNotifier.fireTestFinished();
LocalDriver.destroy();
}
}
Aggregations