use of org.junit.runner.notification.RunListener in project lucene-solr by apache.
the class TestMaxFailuresRule method testZombieThreadFailures.
@Test
public void testZombieThreadFailures() throws Exception {
LuceneTestCase.replaceMaxFailureRule(new TestRuleIgnoreAfterMaxFailures(1));
JUnitCore core = new JUnitCore();
final StringBuilder results = new StringBuilder();
core.addListener(new RunListener() {
char lastTest;
@Override
public void testStarted(Description description) throws Exception {
// success.
lastTest = 'S';
}
@Override
public void testAssumptionFailure(Failure failure) {
// assumption failure.
lastTest = 'A';
}
@Override
public void testFailure(Failure failure) throws Exception {
// failure
lastTest = 'F';
System.out.println(failure.getMessage());
}
@Override
public void testFinished(Description description) throws Exception {
results.append(lastTest);
}
});
Result result = core.run(Nested2.class);
if (Nested2.die != null) {
Nested2.die.countDown();
Nested2.zombie.join();
}
super.prevSysOut.println(results.toString());
Assert.assertEquals(Nested2.TOTAL_ITERS, result.getRunCount());
Assert.assertEquals(results.toString(), "SFAAAAAAAA", results.toString());
}
use of org.junit.runner.notification.RunListener in project drools by kiegroup.
the class ScenarioRunner4JUnitTest method testNoKieWithGivenIDSession.
@Test
public void testNoKieWithGivenIDSession() throws Exception {
HashMap<String, KieSession> ksessions = new HashMap<String, KieSession>();
ksessions.put("someID", ksession);
Scenario scenario = new Scenario();
scenario.getKSessions().add("someOtherID");
ScenarioRunner4JUnit runner4JUnit = new ScenarioRunner4JUnit(scenario, ksessions);
RunNotifier notifier = new RunNotifier();
RunListener runListener = spy(new RunListener());
notifier.addListener(runListener);
runner4JUnit.run(notifier);
verify(runListener).testFailure(any(Failure.class));
}
use of org.junit.runner.notification.RunListener in project drools-wb by kiegroup.
the class ScenarioRunnerService method run.
private void run(final String identifier, final ScenarioRunner4JUnit scenarioRunner, final Event<TestResultMessage> testResultMessageEvent) {
final List<org.guvnor.common.services.shared.test.Failure> failures = new ArrayList<org.guvnor.common.services.shared.test.Failure>();
JUnitCore jUnitCore = new JUnitCore();
jUnitCore.addListener(new RunListener() {
@Override
public void testAssumptionFailure(Failure failure) {
failures.add(failureToFailure(failure));
}
});
Result result = jUnitCore.run(scenarioRunner);
failures.addAll(failuresToFailures(result.getFailures()));
testResultMessageEvent.fire(new TestResultMessage(identifier, result.getRunCount(), result.getRunTime(), failures));
}
use of org.junit.runner.notification.RunListener in project spf4j by zolyfarkas.
the class RunListenerRegisterTest method testRunListenerRegister.
@Test
// this is how RunListenerRegister works..
@SuppressFBWarnings("SEC_SIDE_EFFECT_CONSTRUCTOR")
public void testRunListenerRegister() {
new RunListenerRegister();
RunListener runListener = new RunListener();
RunListenerRegister.addRunListener(runListener, true);
Assert.assertTrue(RunListenerRegister.removeRunListener(runListener));
Assert.assertFalse(RunListenerRegister.removeRunListener(runListener));
try {
new RunListenerRegister();
Assert.fail();
} catch (ExceptionInInitializerError ex) {
// expected
}
}
use of org.junit.runner.notification.RunListener in project calcite-avatica by apache.
the class TestRunner method initializeJUnit.
/**
* Sets up JUnit to run the tests for us.
*/
void initializeJUnit() {
junitCore = new JUnitCore();
junitCore.addListener(new RunListener() {
@Override
public void testStarted(Description description) throws Exception {
LOG.debug("Starting {}", description);
}
@Override
public void testFinished(Description description) throws Exception {
LOG.debug("{}Finished {}{}", ANSI_GREEN, description, ANSI_RESET);
}
@Override
public void testFailure(Failure failure) throws Exception {
LOG.info("{}Failed {}{}", ANSI_RED, failure.getDescription(), ANSI_RESET, failure.getException());
}
});
}
Aggregations