Example usage for junit.framework TestResult errors

List of usage examples for junit.framework TestResult errors

Introduction

In this page you can find the example usage for junit.framework TestResult errors.

Prototype

public synchronized Enumeration<TestFailure> errors() 

Source Link

Document

Returns an Enumeration for the errors

Usage

From source file:org.fhcrc.cpl.toolbox.filehandler.TabLoader.java

public static void main(String[] args) throws Exception {
    try {/*from   w  ww .j av  a 2 s .  com*/
        Class c = Class.forName("org.fhcrc.cpas.data.ConvertHelper");
        c.getMethod("registerHelpers").invoke(null);

        Test test = TabLoaderTestCase.suite();
        TestResult result = new TestResult();
        test.run(result);
        System.out.println(result.wasSuccessful() ? "success" : "fail");

        Enumeration failures = result.failures();
        Throwable first = null;
        while (failures.hasMoreElements()) {
            TestFailure failure = (TestFailure) failures.nextElement();
            System.err.println(failure.toString());
            if (first == null)
                first = failure.thrownException();
        }
        Enumeration errors = result.errors();
        while (errors.hasMoreElements()) {
            TestFailure error = (TestFailure) errors.nextElement();
            System.err.println(error.toString());
            if (first == null)
                first = error.thrownException();
        }
        if (first != null) {
            System.err.println("first exception");
            first.printStackTrace(System.err);
        }
    } catch (Throwable t) {
        t.printStackTrace(System.err);
    }
}