use of org.junit.runner.notification.RunListener in project junit4 by junit-team.
the class MaxStarterTest method listenersAreCalledCorrectlyInTheFaceOfFailures.
@Test
public void listenersAreCalledCorrectlyInTheFaceOfFailures() throws Exception {
JUnitCore core = new JUnitCore();
final List<Failure> failures = new ArrayList<Failure>();
core.addListener(new RunListener() {
@Override
public void testRunFinished(Result result) throws Exception {
failures.addAll(result.getFailures());
}
});
fMax.run(Request.aClass(TwoTests.class), core);
assertEquals(1, failures.size());
}
use of org.junit.runner.notification.RunListener in project junit4 by junit-team.
the class AssumptionTest method failedAssumptionsCanBeDetectedByListeners.
@Test
public void failedAssumptionsCanBeDetectedByListeners() {
assumptionFailures = 0;
JUnitCore core = new JUnitCore();
core.addListener(new RunListener() {
@Override
public void testAssumptionFailure(Failure failure) {
assumptionFailures++;
}
});
core.run(HasFailingAssumption.class);
assertThat(assumptionFailures, is(1));
}
use of org.junit.runner.notification.RunListener in project pact-jvm by DiUS.
the class ExpectedToFailInteractionRunner method run.
@Override
public void run(final RunNotifier notifier) {
RunNotifier testNotifier = new RunNotifier();
testNotifier.addListener(new RunListener() {
@Override
public void testRunStarted(Description description) throws Exception {
notifier.fireTestRunStarted(description);
}
@Override
public void testRunFinished(Result result) throws Exception {
notifier.fireTestRunFinished(result);
}
@Override
public void testStarted(Description description) throws Exception {
notifier.fireTestStarted(description);
}
@Override
public void testFailure(Failure failure) throws Exception {
notifier.fireTestFinished(failure.getDescription());
}
@Override
public void testIgnored(Description description) throws Exception {
notifier.fireTestFailure(new Failure(description, new Exception("Expected the test to fail but it did not")));
}
@Override
public void testFinished(Description description) throws Exception {
notifier.fireTestFailure(new Failure(description, new Exception("Expected the test to fail but it did not")));
}
});
baseRunner.run(testNotifier);
}
use of org.junit.runner.notification.RunListener in project calcite-avatica by apache.
the class TestRunner method initializeJUnit.
/**
* Sets up JUnit to run the tests for us.
*/
void initializeJUnit() {
junitCore = new JUnitCore();
junitCore.addListener(new RunListener() {
@Override
public void testStarted(Description description) throws Exception {
LOG.debug("Starting {}", description);
}
@Override
public void testFinished(Description description) throws Exception {
LOG.debug("{}Finished {}{}", ANSI_GREEN, description, ANSI_RESET);
}
@Override
public void testFailure(Failure failure) throws Exception {
LOG.info("{}Failed {}{}", ANSI_RED, failure.getDescription(), ANSI_RESET, failure.getException());
}
});
}
use of org.junit.runner.notification.RunListener in project xtext-xtend by eclipse.
the class ParameterizedSWTBotRunner method run.
@Override
public void run(RunNotifier notifier) {
RunListener failureSpy = new ScreenshotCaptureListener();
// remove existing listeners that could be added by suite or class runners
notifier.removeListener(failureSpy);
notifier.addListener(failureSpy);
try {
super.run(notifier);
} finally {
notifier.removeListener(failureSpy);
}
}
Aggregations