Code example for TestResult

Methods: errorCounterrorsfailureCountfailures

0
     * 
     */ 
    public AllTests() { 
         
        TestFailure error;     
        TestResult results = new TestResult();
         
        // Execute the Tests 
        suite().run(results);
         
        // Print the run statistics 
        printHeader("Test Results", true); 
        System.out.println("Errors:     " + results.errorCount());        
        System.out.println("Failures:   " + results.failureCount());
        System.out.println("");
         
        // Print out errors 
        if (results.errorCount() > 0) {
            printHeader("Errors", false); 
            for (Enumeration errors = results.errors() ; errors.hasMoreElements() ;) {
                error = (TestFailure) errors.nextElement();            
                System.out.println("Test:       " + error.failedTest().toString());
                System.out.println("Message:    " + error.exceptionMessage());
                System.out.println("Failure Trace: ");
                System.out.println(error.trace());
                System.out.println("");
           }           
        } 
 
        // Print out failures 
        if (results.failureCount() > 0) {
            printHeader("Failures", false); 
            for (Enumeration failures = results.failures() ; failures.hasMoreElements() ;) {
                error = (TestFailure) failures.nextElement();
                System.out.println("Test:       " + error.failedTest().toString());
                System.out.println("Message:    " + error.exceptionMessage());
                System.out.println("Failure Trace: ");
                System.out.println(error.trace());