Search in sources :

Example 6 with RunListener

use of org.junit.runner.notification.RunListener in project verify-hub by alphagov.

the class InfinispanJunitRunner method run.

@Override
public void run(final RunNotifier notifier) {
    notifier.addListener(new RunListener() {

        @Override
        public void testStarted(Description description) throws Exception {
            super.testStarted(description);
        }

        @Override
        public void testFinished(Description description) throws Exception {
            super.testFinished(description);
            EMBEDDED_CACHE_MANAGER.getCache("state_cache").clear();
            EMBEDDED_CACHE_MANAGER.getCache("assertion_id_cache").clear();
        }
    });
    super.run(notifier);
}
Also used : Description(org.junit.runner.Description) InvocationTargetException(java.lang.reflect.InvocationTargetException) RunListener(org.junit.runner.notification.RunListener)

Example 7 with RunListener

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

the class ScenarioRunner4JUnitTest method testBasic.

@Test
public void testBasic() throws Exception {
    HashMap<String, KieSession> ksessions = new HashMap<String, KieSession>();
    ksessions.put("someId", ksession);
    Scenario scenario = new Scenario();
    scenario.getKSessions().add("someId");
    ScenarioRunner4JUnit runner4JUnit = new ScenarioRunner4JUnit(scenario, ksessions);
    RunNotifier notifier = new RunNotifier();
    RunListener runListener = spy(new RunListener());
    notifier.addListener(runListener);
    runner4JUnit.run(notifier);
    verify(runListener, never()).testFailure(any(Failure.class));
    verify(runListener).testFinished(any(Description.class));
    verify(ksession).reset();
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Description(org.junit.runner.Description) HashMap(java.util.HashMap) KieSession(org.kie.api.runtime.KieSession) Failure(org.junit.runner.notification.Failure) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test)

Example 8 with RunListener

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

the class ScenarioRunner4JUnitTest method testIDNotSet.

@Test
public void testIDNotSet() throws Exception {
    HashMap<String, KieSession> ksessions = new HashMap<String, KieSession>();
    ksessions.put(null, ksession);
    ScenarioRunner4JUnit runner4JUnit = new ScenarioRunner4JUnit(new Scenario(), ksessions);
    RunNotifier notifier = new RunNotifier();
    RunListener runListener = spy(new RunListener());
    notifier.addListener(runListener);
    runner4JUnit.run(notifier);
    verify(runListener, never()).testFailure(any(Failure.class));
    verify(runListener).testFinished(any(Description.class));
    verify(ksession).reset();
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Description(org.junit.runner.Description) HashMap(java.util.HashMap) KieSession(org.kie.api.runtime.KieSession) Failure(org.junit.runner.notification.Failure) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test)

Example 9 with RunListener

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

the class ScenarioRunner4JUnitTest method testNoKieSession.

@Test
public void testNoKieSession() throws Exception {
    ScenarioRunner4JUnit runner4JUnit = new ScenarioRunner4JUnit(new Scenario(), new HashMap<String, KieSession>());
    RunNotifier notifier = new RunNotifier();
    RunListener runListener = spy(new RunListener());
    notifier.addListener(runListener);
    runner4JUnit.run(notifier);
    verify(runListener).testFailure(any(Failure.class));
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) KieSession(org.kie.api.runtime.KieSession) Failure(org.junit.runner.notification.Failure) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.Test)

Example 10 with RunListener

use of org.junit.runner.notification.RunListener in project devonfw-testing by devonfw.

the class TestWatcherExceptionTest method initJUnit.

@BeforeClass
public static void initJUnit() {
    BFLogger.logInfo("Starting base test");
    computer = new Computer();
    jUnitCore = new JUnitCore();
    jUnitCore.addListener(new RunListener() {

        @Override
        public void testFailure(Failure failure) throws Exception {
            thrownException = failure.getException();
            BFLogger.logInfo("An exception has been thrown: " + thrownException.getMessage());
        }
    });
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Computer(org.junit.runner.Computer) Failure(org.junit.runner.notification.Failure) BFInputDataException(com.capgemini.ntc.test.core.exceptions.BFInputDataException) RunListener(org.junit.runner.notification.RunListener) BeforeClass(org.junit.BeforeClass)

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