Search in sources :

Example 46 with RunListener

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());
}
Also used : JUnitCore(org.junit.runner.JUnitCore) ArrayList(java.util.ArrayList) Failure(org.junit.runner.notification.Failure) RunListener(org.junit.runner.notification.RunListener) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 47 with RunListener

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));
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Failure(org.junit.runner.notification.Failure) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test)

Example 48 with RunListener

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);
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Description(org.junit.runner.Description) Failure(org.junit.runner.notification.Failure) RunListener(org.junit.runner.notification.RunListener) Result(org.junit.runner.Result)

Example 49 with RunListener

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());
        }
    });
}
Also used : Description(org.junit.runner.Description) JUnitCore(org.junit.runner.JUnitCore) SQLException(java.sql.SQLException) Failure(org.junit.runner.notification.Failure) RunListener(org.junit.runner.notification.RunListener)

Example 50 with RunListener

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);
    }
}
Also used : ScreenshotCaptureListener(org.eclipse.swtbot.swt.finder.junit.ScreenshotCaptureListener) RunListener(org.junit.runner.notification.RunListener)

Aggregations

RunListener (org.junit.runner.notification.RunListener)51 Failure (org.junit.runner.notification.Failure)25 Description (org.junit.runner.Description)21 JUnitCore (org.junit.runner.JUnitCore)20 Result (org.junit.runner.Result)19 Test (org.junit.Test)18 RunNotifier (org.junit.runner.notification.RunNotifier)13 Request (org.junit.runner.Request)6 ArrayList (java.util.ArrayList)5 IOException (java.io.IOException)4 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)3 TextListener (org.junit.internal.TextListener)3 KieSession (org.kie.api.runtime.KieSession)3 KeyManagementException (java.security.KeyManagementException)2 KeyStoreException (java.security.KeyStoreException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 UnrecoverableKeyException (java.security.UnrecoverableKeyException)2 CertificateException (java.security.cert.CertificateException)2 HashMap (java.util.HashMap)2 ScenarioUtil.failureToFailure (org.drools.workbench.screens.testscenario.backend.server.ScenarioUtil.failureToFailure)2