Search in sources :

Example 6 with EachTestNotifier

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

the class ScenarioRunner4JUnit method runScenario.

private void runScenario(RunNotifier notifier, Scenario scenario) {
    Description childDescription = Description.createTestDescription(getClass(), scenario.getName());
    descr.addChild(childDescription);
    EachTestNotifier eachNotifier = new EachTestNotifier(notifier, childDescription);
    try {
        eachNotifier.fireTestStarted();
        // If a KieSession is not available, fail fast
        if (ksessions == null || ksessions.values().isEmpty()) {
            eachNotifier.addFailure(new NullKieSessionException("Unable to get a Session to run tests. Check the project for build errors."));
        } else {
            KieSession ksession = getKSession(scenario.getKSessions());
            if (ksession == null) {
                String ksessionName = getKSessionName(scenario.getKSessions());
                if (ksessionName == null) {
                    eachNotifier.addFailure(new NullPointerException("Test scenario runner could not find the default knowledge session."));
                } else {
                    eachNotifier.addFailure(new NullPointerException("Test Scenarios require Stateful KieSession to run."));
                }
            } else {
                final ScenarioRunner runner = new ScenarioRunner(ksession, maxRuleFirings);
                runner.run(scenario);
                if (!scenario.wasSuccessful()) {
                    StringBuilder builder = new StringBuilder();
                    for (String message : scenario.getFailureMessages()) {
                        builder.append(message).append("\n");
                    }
                    eachNotifier.addFailedAssumption(new AssumptionViolatedException(builder.toString()));
                }
                // FLUSSSSSH!
                for (FactHandle factHandle : ksession.getFactHandles()) {
                    ksession.delete(factHandle);
                }
                resetKieSession(ksession);
            }
        }
    } catch (Throwable t) {
        eachNotifier.addFailure(t);
    } finally {
        // has to always be called as per junit docs
        eachNotifier.fireTestFinished();
    }
}
Also used : Description(org.junit.runner.Description) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) FactHandle(org.kie.api.runtime.rule.FactHandle) EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier) KieSession(org.kie.api.runtime.KieSession)

Example 7 with EachTestNotifier

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

the class VMRequirements method ignoreTest.

private void ignoreTest(FrameworkMethod method, RunNotifier notifier, Description description) {
    EachTestNotifier eachTestNotifier = new EachTestNotifier(notifier, description);
    eachTestNotifier.fireTestIgnored();
}
Also used : EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier)

Example 8 with EachTestNotifier

use of org.junit.internal.runners.model.EachTestNotifier in project devonfw-testing by devonfw.

the class ParallelTestClassRunner method run.

@Override
public void run(final RunNotifier notifier) {
    EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription());
    try {
        Statement statement = classBlock(notifier);
        statement.evaluate();
    } catch (AssumptionViolatedException e) {
        testNotifier.addFailedAssumption(e);
    } catch (StoppedByUserException e) {
        throw e;
    } catch (Throwable e) {
        testNotifier.addFailure(e);
    } finally {
    }
}
Also used : AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) Statement(org.junit.runners.model.Statement) EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier) StoppedByUserException(org.junit.runner.notification.StoppedByUserException)

Example 9 with EachTestNotifier

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

the class FlinkEmbeddedHiveRunner method runChild.

@Override
protected void runChild(final FrameworkMethod method, RunNotifier notifier) {
    Description description = describeChild(method);
    if (method.getAnnotation(Ignore.class) != null) {
        notifier.fireTestIgnored(description);
    } else {
        EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
        eachNotifier.fireTestStarted();
        try {
            runTestMethod(method, eachNotifier);
        } finally {
            eachNotifier.fireTestFinished();
        }
    }
}
Also used : Ignore(org.junit.Ignore) Description(org.junit.runner.Description) EachTestNotifier(org.junit.internal.runners.model.EachTestNotifier)

Example 10 with EachTestNotifier

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

the class RetryTestRunner method runTestUnit.

private void runTestUnit(final Statement statement, final Description description, final RunNotifier notifier) {
    final EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
    eachNotifier.fireTestStarted();
    try {
        statement.evaluate();
    } catch (AssumptionViolatedException e) {
        eachNotifier.addFailedAssumption(e);
    } catch (Throwable e) {
        retry(description, eachNotifier, statement, e);
    } 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