Search in sources :

Example 16 with RunListener

use of org.junit.runner.notification.RunListener in project j2objc by google.

the class JUnitTestRunner method run.

/**
 * Runs the test classes that match settings in {@link #PROPERTIES_FILE_NAME}.
 * @returns Zero if all tests pass, non-zero otherwise.
 */
public int run() {
    if (outputFormat == OutputFormat.GTM_UNIT_TESTING) {
        Thread.setDefaultUncaughtExceptionHandler(new GtmUncaughtExceptionHandler());
    }
    Set<Class<?>> classesSet = getTestClasses();
    Class<?>[] classes = classesSet.toArray(new Class<?>[classesSet.size()]);
    sortClasses(classes, sortOrder);
    RunListener listener = newRunListener(outputFormat);
    return run(classes, listener);
}
Also used : RunListener(org.junit.runner.notification.RunListener)

Example 17 with RunListener

use of org.junit.runner.notification.RunListener in project junit4 by junit-team.

the class AssumptionTest method runAndGetAssumptionFailures.

/**
 * Helper method that runs tests on <code>clazz</code> and returns any
 * {@link Failure} objects that were {@link AssumptionViolatedException}s.
 */
private static List<Failure> runAndGetAssumptionFailures(Class<?> clazz) {
    final List<Failure> failures = new ArrayList<Failure>();
    final JUnitCore core = new JUnitCore();
    core.addListener(new RunListener() {

        @Override
        public void testAssumptionFailure(Failure failure) {
            failures.add(failure);
        }
    });
    core.run(clazz);
    return failures;
}
Also used : JUnitCore(org.junit.runner.JUnitCore) ArrayList(java.util.ArrayList) Failure(org.junit.runner.notification.Failure) RunListener(org.junit.runner.notification.RunListener)

Example 18 with RunListener

use of org.junit.runner.notification.RunListener in project junit4 by junit-team.

the class JUnit38ClassRunnerTest method testListener.

@Test
public void testListener() throws Exception {
    JUnitCore runner = new JUnitCore();
    RunListener listener = new RunListener() {

        @Override
        public void testStarted(Description description) {
            assertEquals(Description.createTestDescription(OneTest.class, "testOne"), description);
            count++;
        }
    };
    runner.addListener(listener);
    count = 0;
    Result result = runner.run(OneTest.class);
    assertEquals(1, count);
    assertEquals(1, result.getRunCount());
}
Also used : Description(org.junit.runner.Description) JUnitCore(org.junit.runner.JUnitCore) RunListener(org.junit.runner.notification.RunListener) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 19 with RunListener

use of org.junit.runner.notification.RunListener in project junit4 by junit-team.

the class OldTestClassAdaptingListenerTest method addFailureDelegatesToNotifier.

@Test
public void addFailureDelegatesToNotifier() {
    Result result = new Result();
    RunListener listener = result.createListener();
    RunNotifier notifier = new RunNotifier();
    notifier.addFirstListener(listener);
    TestCase testCase = new TestCase() {
    };
    TestListener adaptingListener = new JUnit38ClassRunner(testCase).createAdaptingListener(notifier);
    adaptingListener.addFailure(testCase, new AssertionFailedError());
    assertEquals(1, result.getFailureCount());
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) TestCase(junit.framework.TestCase) JUnit38ClassRunner(org.junit.internal.runners.JUnit38ClassRunner) TestListener(junit.framework.TestListener) AssertionFailedError(junit.framework.AssertionFailedError) Result(org.junit.runner.Result) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test)

Example 20 with RunListener

use of org.junit.runner.notification.RunListener in project junit4 by junit-team.

the class RunnerTest method testFinished.

@Test
public void testFinished() {
    JUnitCore runner = new JUnitCore();
    wasRun = false;
    RunListener listener = new MyListener() {

        @Override
        public void testFinished(Description description) {
            wasRun = true;
        }
    };
    runner.addListener(listener);
    runner.run(NewExample.class);
    assertTrue(wasRun);
}
Also used : Description(org.junit.runner.Description) JUnitCore(org.junit.runner.JUnitCore) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test)

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