Search in sources :

Example 21 with EachTestNotifier

use of org.junit.internal.runners.model.EachTestNotifier in project google-cloud-java by GoogleCloudPlatform.

the class ReadFormatTestRunner method runChild.

@Override
protected void runChild(JSONObject child, RunNotifier notifier) {
    EachTestNotifier eachNotifier = new EachTestNotifier(notifier, describeChild(child));
    eachNotifier.fireTestStarted();
    try {
        new TestCaseRunner(child).run();
        eachNotifier.fireTestFinished();
    } catch (Exception | AssertionError e) {
        eachNotifier.addFailure(e);
    }
}
Also used : EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier) JSONException(org.json.JSONException)

Example 22 with EachTestNotifier

use of org.junit.internal.runners.model.EachTestNotifier in project mapstruct by mapstruct.

the class ProcessorSuiteRunner method runChild.

@Override
protected void runChild(ProcessorTestCase child, RunNotifier notifier) {
    Description description = describeChild(child);
    EachTestNotifier testNotifier = new EachTestNotifier(notifier, description);
    if (child.ignored) {
        testNotifier.fireTestIgnored();
    } else {
        try {
            testNotifier.fireTestStarted();
            doExecute(child, description);
        } catch (AssumptionViolatedException e) {
            testNotifier.fireTestIgnored();
        } catch (StoppedByUserException e) {
            throw e;
        } catch (Throwable e) {
            testNotifier.addFailure(e);
        } finally {
            testNotifier.fireTestFinished();
        }
    }
}
Also used : ProviderDescription(org.mapstruct.itest.testutil.runner.xml.Toolchains.ProviderDescription) Description(org.junit.runner.Description) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier) StoppedByUserException(org.junit.runner.notification.StoppedByUserException)

Example 23 with EachTestNotifier

use of org.junit.internal.runners.model.EachTestNotifier in project pravega by pravega.

the class SystemTestRunner method invokeTest.

private void invokeTest(RunNotifier notifier, TestExecutorType type, FrameworkMethod method) {
    if ((type == null) || TestExecutorType.LOCAL.equals(type)) {
        runLeaf(methodBlock(method), describeChild(method), notifier);
    } else {
        EachTestNotifier eachNotifier = new EachTestNotifier(notifier, describeChild(method));
        try {
            eachNotifier.fireTestStarted();
            execute(type, method.getMethod()).get();
        } catch (Throwable e) {
            log.error("Test " + method + " failed with exception ", e);
            eachNotifier.addFailure(unwrap(e));
        } finally {
            eachNotifier.fireTestFinished();
        }
    }
}
Also used : EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier)

Example 24 with EachTestNotifier

use of org.junit.internal.runners.model.EachTestNotifier in project pinpoint by naver.

the class PinpointJUnit4ClassRunner method endTracing.

private void endTracing(FrameworkMethod method, RunNotifier notifier) {
    if (shouldCreateNewTraceObject(method)) {
        TraceContext traceContext = getTraceContext();
        try {
            Trace trace = traceContext.currentRawTraceObject();
            if (trace == null) {
                // Trace is already detached from the ThreadLocal storage.
                // Happens when root trace method is tested without @IsRootSpan.
                EachTestNotifier testMethodNotifier = new EachTestNotifier(notifier, super.describeChild(method));
                String traceObjectAlreadyDetachedMessage = "Trace object already detached. If you're testing a trace root, please add @IsRootSpan to the test method";
                testMethodNotifier.addFailure(new IllegalStateException(traceObjectAlreadyDetachedMessage));
            } else {
                trace.close();
            }
        } finally {
            traceContext.removeTraceObject();
        }
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier) TraceContext(com.navercorp.pinpoint.bootstrap.context.TraceContext)

Example 25 with EachTestNotifier

use of org.junit.internal.runners.model.EachTestNotifier in project java-sdk by watson-developer-cloud.

the class RetryRunner method runTest.

private void runTest(Statement statement, Description description, RunNotifier notifier) {
    EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
    eachNotifier.fireTestStarted();
    try {
        statement.evaluate();
    } catch (AssumptionViolatedException e) {
        eachNotifier.addFailedAssumption(e);
    } catch (Throwable e) {
        LOG.warning("Retry test: " + description.getDisplayName());
        retry(eachNotifier, statement, e, description);
    } finally {
        eachNotifier.fireTestFinished();
    }
}
Also used : AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier)

Aggregations

EachTestNotifier (org.junit.internal.runners.model.EachTestNotifier)30 AssumptionViolatedException (org.junit.internal.AssumptionViolatedException)12 Test (org.junit.Test)10 Result (gherkin.formatter.model.Result)8 Description (org.junit.runner.Description)6 PendingException (cucumber.api.PendingException)5 StoppedByUserException (org.junit.runner.notification.StoppedByUserException)5 Statement (org.junit.runners.model.Statement)4 Match (gherkin.formatter.model.Match)3 Ignore (org.junit.Ignore)2 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)1 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)1 Step (gherkin.formatter.model.Step)1 ArrayList (java.util.ArrayList)1 JSONException (org.json.JSONException)1 MultipleFailureException (org.junit.internal.runners.model.MultipleFailureException)1 InitializationError (org.junit.runners.model.InitializationError)1 KieSession (org.kie.api.runtime.KieSession)1 FactHandle (org.kie.api.runtime.rule.FactHandle)1 ProviderDescription (org.mapstruct.itest.testutil.runner.xml.Toolchains.ProviderDescription)1