Search in sources :

Example 36 with RunNotifier

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;
}
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)

Example 37 with RunNotifier

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());
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) BlockJUnit4ClassRunner(org.junit.runners.BlockJUnit4ClassRunner)

Example 38 with 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);
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) BlockJUnit4ClassRunner(org.junit.runners.BlockJUnit4ClassRunner) RunnerScheduler(org.junit.runners.model.RunnerScheduler) Test(org.junit.Test)

Example 39 with RunNotifier

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

Example 40 with RunNotifier

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);
}
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)

Aggregations

RunNotifier (org.junit.runner.notification.RunNotifier)53 Failure (org.junit.runner.notification.Failure)16 Description (org.junit.runner.Description)15 Test (org.junit.Test)14 RunListener (org.junit.runner.notification.RunListener)13 Test (org.junit.jupiter.api.Test)9 Runner (org.junit.runner.Runner)9 InOrder (org.mockito.InOrder)7 Feature (io.cucumber.core.gherkin.Feature)5 ArrayList (java.util.ArrayList)5 Before (org.junit.Before)5 Request (org.junit.runner.Request)5 Result (org.junit.runner.Result)5 ParentRunner (org.junit.runners.ParentRunner)4 HashMap (java.util.HashMap)3 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)3 BlockJUnit4ClassRunner (org.junit.runners.BlockJUnit4ClassRunner)3 KieSession (org.kie.api.runtime.KieSession)3 Match (gherkin.formatter.model.Match)2 Scenario (gherkin.formatter.model.Scenario)2