Example usage for junit.framework TestResult failures

List of usage examples for junit.framework TestResult failures

Introduction

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

Prototype

public synchronized Enumeration<TestFailure> failures() 

Source Link

Document

Returns an Enumeration for the failures

Usage

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

public static void main(String[] args) throws Exception {
    try {//from  www  .  jav  a 2 s  .c o  m
        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);
    }
}