Search in sources :

Example 36 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)

Example 37 with RunListener

use of org.junit.runner.notification.RunListener in project drools-wb by kiegroup.

the class ScenarioRunnerService method run.

private TestResultMessage run(final String identifier, final Path path, final ScenarioRunner4JUnit scenarioRunner) {
    final List<org.guvnor.common.services.shared.test.Failure> failures = new ArrayList<org.guvnor.common.services.shared.test.Failure>();
    final JUnitCore jUnitCore = new JUnitCore();
    jUnitCore.addListener(new RunListener() {

        @Override
        public void testAssumptionFailure(Failure failure) {
            failures.add(failureToFailure(path, failure));
        }
    });
    final Result result = jUnitCore.run(scenarioRunner);
    failures.addAll(failuresToFailures(path, result.getFailures()));
    return new TestResultMessage(identifier, result.getRunCount(), result.getRunTime(), failures);
}
Also used : JUnitCore(org.junit.runner.JUnitCore) TestResultMessage(org.guvnor.common.services.shared.test.TestResultMessage) ArrayList(java.util.ArrayList) RunListener(org.junit.runner.notification.RunListener) Result(org.junit.runner.Result) TestScenarioResult(org.drools.workbench.screens.testscenario.model.TestScenarioResult) ScenarioUtil.failureToFailure(org.drools.workbench.screens.testscenario.backend.server.ScenarioUtil.failureToFailure) Failure(org.junit.runner.notification.Failure)

Example 38 with RunListener

use of org.junit.runner.notification.RunListener in project squidb by yahoo.

the class SquidbTestRunner 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() {
    Set<Class> classesSet = getTestClasses();
    Class[] classes = classesSet.toArray(new Class[classesSet.size()]);
    sortClasses(classes, sortOrder);
    RunListener listener = newRunListener(outputFormat);
    return run(classes, listener, out);
}
Also used : RunListener(org.junit.runner.notification.RunListener)

Example 39 with RunListener

use of org.junit.runner.notification.RunListener in project nutz by nutzam.

the class AdvancedTestAll method test.

public static TestResult test(List<Request> reqs, String name, Map<Request, Method> reqMap) {
    // TODO 根据order文件还原测试顺序
    try {
        FileWriter fw = new FileWriter("./test_order_" + name + ".txt");
        for (Request request : reqs) {
            fw.write(reqMap.get(request).toString());
            fw.write("\n");
        }
        fw.flush();
        fw.close();
    } catch (IOException e) {
    }
    final TestResult result = new TestResult();
    RunNotifier notifier = new RunNotifier();
    notifier.addListener(new RunListener() {

        public void testFailure(Failure failure) throws Exception {
            result.addError(asTest(failure.getDescription()), failure.getException());
        }

        public void testFinished(Description description) throws Exception {
            result.endTest(asTest(description));
        }

        public void testStarted(Description description) throws Exception {
            result.startTest(asTest(description));
        }

        public junit.framework.Test asTest(Description description) {
            return new junit.framework.Test() {

                public void run(TestResult result) {
                    throw Lang.noImplement();
                }

                public int countTestCases() {
                    return 1;
                }
            };
        }
    });
    for (Request request : reqs) {
        request.getRunner().run(notifier);
    }
    return result;
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Description(org.junit.runner.Description) FileWriter(java.io.FileWriter) Request(org.junit.runner.Request) TestResult(junit.framework.TestResult) IOException(java.io.IOException) IOException(java.io.IOException) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test) TestFailure(junit.framework.TestFailure) Failure(org.junit.runner.notification.Failure)

Example 40 with RunListener

use of org.junit.runner.notification.RunListener in project cucumber-jvm by cucumber.

the class CucumberTest method cucumber_can_run_features_in_parallel.

@Test
void cucumber_can_run_features_in_parallel() throws Exception {
    RunNotifier notifier = new RunNotifier();
    RunListener listener = Mockito.mock(RunListener.class);
    notifier.addListener(listener);
    ParallelComputer computer = new ParallelComputer(true, true);
    Request.classes(computer, ValidEmpty.class).getRunner().run(notifier);
    {
        InOrder order = Mockito.inOrder(listener);
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("Followed by some examples #1(Feature A)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("Followed by some examples #1(Feature A)")));
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("Followed by some examples #2(Feature A)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("Followed by some examples #2(Feature A)")));
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("Followed by some examples #3(Feature A)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("Followed by some examples #3(Feature A)")));
    }
    {
        InOrder order = Mockito.inOrder(listener);
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("A(Feature B)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("A(Feature B)")));
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("B(Feature B)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("B(Feature B)")));
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("C #1(Feature B)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("C #1(Feature B)")));
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("C #2(Feature B)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("C #2(Feature B)")));
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("C #3(Feature B)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("C #3(Feature B)")));
    }
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) InOrder(org.mockito.InOrder) ParallelComputer(org.junit.experimental.ParallelComputer) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.jupiter.api.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