Search in sources :

Example 46 with RunNotifier

use of org.junit.runner.notification.RunNotifier in project robolectric by robolectric.

the class RobolectricTestRunnerMultiApiTest method setUp.

@Before
public void setUp() {
    numSupportedApis = APIS_FOR_TEST.length;
    runListener = new MyRunListener();
    runNotifier = new RunNotifier();
    runNotifier.addListener(runListener);
    sdkCollection = new SdkCollection(() -> map(APIS_FOR_TEST));
    delegateSdkPicker = new DefaultSdkPicker(sdkCollection, null);
    priorResourcesMode = System.getProperty("robolectric.resourcesMode");
    System.setProperty("robolectric.resourcesMode", "legacy");
    priorAlwaysInclude = System.getProperty("robolectric.alwaysIncludeVariantMarkersInTestName");
    System.clearProperty("robolectric.alwaysIncludeVariantMarkersInTestName");
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) SdkCollection(org.robolectric.plugins.SdkCollection) DefaultSdkPicker(org.robolectric.plugins.DefaultSdkPicker) Before(org.junit.Before)

Example 47 with RunNotifier

use of org.junit.runner.notification.RunNotifier in project robolectric by robolectric.

the class RobolectricTestRunnerTest method setUp.

@Before
public void setUp() throws Exception {
    notifier = new RunNotifier();
    events = new ArrayList<>();
    notifier.addListener(new MyRunListener());
    priorEnabledSdks = System.getProperty("robolectric.enabledSdks");
    System.clearProperty("robolectric.enabledSdks");
    priorAlwaysInclude = System.getProperty("robolectric.alwaysIncludeVariantMarkersInTestName");
    System.clearProperty("robolectric.alwaysIncludeVariantMarkersInTestName");
    sdkCollection = TestUtil.getSdkCollection();
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Before(org.junit.Before)

Example 48 with RunNotifier

use of org.junit.runner.notification.RunNotifier in project robolectric by robolectric.

the class TestRunnerSequenceTest method run.

private Result run(Runner runner) throws InitializationError {
    RunNotifier notifier = new RunNotifier();
    Result result = new Result();
    notifier.addListener(result.createListener());
    runner.run(notifier);
    return result;
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Result(org.junit.runner.Result)

Example 49 with RunNotifier

use of org.junit.runner.notification.RunNotifier in project robolectric by robolectric.

the class TestRunnerSequenceTest method shouldReleaseAllStateAfterClassSoWeDontLeakMemory.

@Test
public void shouldReleaseAllStateAfterClassSoWeDontLeakMemory() throws Exception {
    final List<RobolectricTestRunner.RobolectricFrameworkMethod> methods = new ArrayList<>();
    RobolectricTestRunner robolectricTestRunner = new Runner(SimpleTest.class) {

        @Override
        protected void finallyAfterTest(FrameworkMethod method) {
            super.finallyAfterTest(method);
            RobolectricFrameworkMethod roboMethod = (RobolectricFrameworkMethod) method;
            assertThat(roboMethod.getTestEnvironment()).isNull();
            assertThat(roboMethod.testLifecycle).isNull();
            methods.add(roboMethod);
        }
    };
    robolectricTestRunner.run(new RunNotifier());
    assertThat(methods).isNotEmpty();
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) ArrayList(java.util.ArrayList) FrameworkMethod(org.junit.runners.model.FrameworkMethod) Test(org.junit.Test)

Example 50 with RunNotifier

use of org.junit.runner.notification.RunNotifier in project robolectric by robolectric.

the class FailureListener method runTests.

@Nonnull
public static List<Failure> runTests(Class<?> testClass) throws InitializationError {
    RunNotifier notifier = new RunNotifier();
    FailureListener failureListener = new FailureListener();
    notifier.addListener(failureListener);
    new RobolectricTestRunner(testClass).run(notifier);
    return failureListener.failures;
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) RobolectricTestRunner(org.robolectric.RobolectricTestRunner) Nonnull(javax.annotation.Nonnull)

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