use of org.junit.runner.notification.RunNotifier in project junit4 by junit-team.
the class JUnit4TestAdapterCache method getNotifier.
public RunNotifier getNotifier(final TestResult result, final JUnit4TestAdapter adapter) {
RunNotifier notifier = new RunNotifier();
notifier.addListener(new RunListener() {
@Override
public void testFailure(Failure failure) throws Exception {
result.addError(asTest(failure.getDescription()), failure.getException());
}
@Override
public void testFinished(Description description) throws Exception {
result.endTest(asTest(description));
}
@Override
public void testStarted(Description description) throws Exception {
result.startTest(asTest(description));
}
});
return notifier;
}
use of org.junit.runner.notification.RunNotifier in project junit4 by junit-team.
the class ParentRunnerClassLoaderTest method runTestWithParentRunner.
private void runTestWithParentRunner(Class<?> testClass) throws InitializationError {
ParentRunner<?> runner = new BlockJUnit4ClassRunner(testClass);
runner.run(new RunNotifier());
}
use of org.junit.runner.notification.RunNotifier in project junit4 by junit-team.
the class ParentRunnerTest method useChildHarvester.
@Test
public void useChildHarvester() throws InitializationError {
log = "";
ParentRunner<?> runner = new BlockJUnit4ClassRunner(FruitTest.class);
runner.setScheduler(new RunnerScheduler() {
public void schedule(Runnable childStatement) {
log += "before ";
childStatement.run();
log += "after ";
}
public void finished() {
log += "afterAll ";
}
});
runner.run(new RunNotifier());
assertEquals("before apple after before banana after afterAll ", log);
}
use of org.junit.runner.notification.RunNotifier in project junit4 by junit-team.
the class CustomBlockJUnit4ClassRunnerTest method exceptionsFromMethodBlockMustNotResultInUnrootedTests.
@Test
public void exceptionsFromMethodBlockMustNotResultInUnrootedTests() throws Exception {
TrackingRunListener listener = new TrackingRunListener();
RunNotifier notifier = new RunNotifier();
notifier.addListener(listener);
new CustomBlockJUnit4ClassRunner(CustomBlockJUnit4ClassRunnerTestCase.class).run(notifier);
assertEquals("tests started.", 2, listener.testStartedCount.get());
assertEquals("tests failed.", 1, listener.testFailureCount.get());
assertEquals("tests finished.", 2, listener.testFinishedCount.get());
}
use of org.junit.runner.notification.RunNotifier 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);
}
Aggregations