use of org.junit.runner.notification.RunListener in project j2objc by google.
the class JUnitTestRunner method run.
/**
* Runs the test classes that match settings in {@link #PROPERTIES_FILE_NAME}.
* @returns Zero if all tests pass, non-zero otherwise.
*/
public int run() {
if (outputFormat == OutputFormat.GTM_UNIT_TESTING) {
Thread.setDefaultUncaughtExceptionHandler(new GtmUncaughtExceptionHandler());
}
Set<Class<?>> classesSet = getTestClasses();
Class<?>[] classes = classesSet.toArray(new Class<?>[classesSet.size()]);
sortClasses(classes, sortOrder);
RunListener listener = newRunListener(outputFormat);
return run(classes, listener);
}
use of org.junit.runner.notification.RunListener in project junit4 by junit-team.
the class AssumptionTest method runAndGetAssumptionFailures.
/**
* Helper method that runs tests on <code>clazz</code> and returns any
* {@link Failure} objects that were {@link AssumptionViolatedException}s.
*/
private static List<Failure> runAndGetAssumptionFailures(Class<?> clazz) {
final List<Failure> failures = new ArrayList<Failure>();
final JUnitCore core = new JUnitCore();
core.addListener(new RunListener() {
@Override
public void testAssumptionFailure(Failure failure) {
failures.add(failure);
}
});
core.run(clazz);
return failures;
}
use of org.junit.runner.notification.RunListener in project junit4 by junit-team.
the class JUnit38ClassRunnerTest method testListener.
@Test
public void testListener() throws Exception {
JUnitCore runner = new JUnitCore();
RunListener listener = new RunListener() {
@Override
public void testStarted(Description description) {
assertEquals(Description.createTestDescription(OneTest.class, "testOne"), description);
count++;
}
};
runner.addListener(listener);
count = 0;
Result result = runner.run(OneTest.class);
assertEquals(1, count);
assertEquals(1, result.getRunCount());
}
use of org.junit.runner.notification.RunListener in project junit4 by junit-team.
the class OldTestClassAdaptingListenerTest method addFailureDelegatesToNotifier.
@Test
public void addFailureDelegatesToNotifier() {
Result result = new Result();
RunListener listener = result.createListener();
RunNotifier notifier = new RunNotifier();
notifier.addFirstListener(listener);
TestCase testCase = new TestCase() {
};
TestListener adaptingListener = new JUnit38ClassRunner(testCase).createAdaptingListener(notifier);
adaptingListener.addFailure(testCase, new AssertionFailedError());
assertEquals(1, result.getFailureCount());
}
use of org.junit.runner.notification.RunListener in project junit4 by junit-team.
the class RunnerTest method testFinished.
@Test
public void testFinished() {
JUnitCore runner = new JUnitCore();
wasRun = false;
RunListener listener = new MyListener() {
@Override
public void testFinished(Description description) {
wasRun = true;
}
};
runner.addListener(listener);
runner.run(NewExample.class);
assertTrue(wasRun);
}
Aggregations