Package junit.framework

Examples of junit.framework.TestFailure


     * @param theTest the test object that failed
     * @param theThrowable the exception that was thrown
     */
    public void addError(Test theTest, Throwable theThrowable)
    {
        TestFailure failure = new TestFailure(theTest, theThrowable);
        StringBuffer xml = new StringBuffer();

        xml.append("<" + ERROR + " " + ATTR_MESSAGE + "=\""
            + xmlEncode(failure.thrownException().getMessage()) + "\" "
            + ATTR_TYPE + "=\""
            + failure.thrownException().getClass().getName() + "\">");
        xml.append(xmlEncode(
            StringUtil.exceptionToString(failure.thrownException())));
        xml.append("</" + ERROR + ">");

        this.currentTestFailure = xml.toString();
    }
View Full Code Here


     * @param theTest the test object that failed
     * @param theError the exception that was thrown
     */
    public void addFailure(Test theTest, AssertionFailedError theError)
    {
        TestFailure failure = new TestFailure(theTest, theError);
        StringBuffer xml = new StringBuffer();

        xml.append("<" + FAILURE + " " + ATTR_MESSAGE + "=\""
            + xmlEncode(failure.thrownException().getMessage())
            + "\" " + ATTR_TYPE + "=\""
            + failure.thrownException().getClass().getName() + "\">");
        xml.append(xmlEncode(
            StringUtil.exceptionToString(failure.thrownException())));
        xml.append("</" + FAILURE + ">");

        this.currentTestFailure = xml.toString();
    }
View Full Code Here

                        sresult.setResponseCode(getFailureCode());
                        buf.append( getFailure() );
                        buf.append("\n");
                    }
                    while (en.hasMoreElements()){
                        TestFailure item = en.nextElement();
                        buf.append( "Failure -- ");
                        buf.append( item.toString() );
                        buf.append("\n");
                        buftrace.append( "Failure -- ");
                        buftrace.append( item.toString() );
                        buftrace.append("\n");
                        buftrace.append( "Trace -- ");
                        buftrace.append( item.trace() );
                    }
                    en = tr.errors();
                    if (en.hasMoreElements()){
                        sresult.setResponseCode(getErrorCode());
                        buf.append( getError() );
                        buf.append("\n");
                    }
                    while (en.hasMoreElements()){
                        TestFailure item = en.nextElement();
                        buf.append( "Error -- ");
                        buf.append( item.toString() );
                        buf.append("\n");
                        buftrace.append( "Error -- ");
                        buftrace.append( item.toString() );
                        buftrace.append("\n");
                        buftrace.append( "Trace -- ");
                        buftrace.append( item.trace() );
                    }
                }
                sresult.setResponseMessage(buf.toString());
                sresult.setResponseData(buftrace.toString(), null);
            }
View Full Code Here

                writer().println("There were " + result.failureCount() + " failures:");
           
            int i = 1;
            writer().println("\nFailure Summary:");
            for (final Enumeration e= result.failures(); e.hasMoreElements(); i++) {
                final TestFailure failure= (TestFailure) e.nextElement();
                writer().println(i + ") " + failure.failedTest());
            }
            i = 1;
            writer().println("\nFailure Details:");
            for (final Enumeration e= result.failures(); e.hasMoreElements(); i++) {
                final TestFailure failure= (TestFailure) e.nextElement();
                writer().println("\n"+ i + ") " + failure.failedTest());
                final Throwable t= failure.thrownException();
                if (t.getMessage() != null)
                    writer().println("\t\"" + t.getMessage() + "\"");
                else {
                    writer().println();
                    failure.thrownException().printStackTrace();
                }
            }
        }
    }
View Full Code Here

                writer().println("There were "+result.errorCount()+" errors:");
   
            writer().println("\nError Summary:");
            int i = 1;
            for (final Enumeration e= result.errors(); e.hasMoreElements(); i++) {
                final TestFailure failure= (TestFailure) e.nextElement();
                writer().println(i + ") " + failure.failedTest());
            }
            writer().println("\nError Details:");
            i = 1;
            for (final Enumeration e= result.errors(); e.hasMoreElements(); i++) {
                final TestFailure failure= (TestFailure)e.nextElement();
                writer().println(i+") "+failure.failedTest());
                final String trace = getRelevantStackTrace(failure.thrownException());
                writer().println(trace);
            }
        }
    }
View Full Code Here

    }
   
    private static Object[] getSortedArrayOfErrorSummaryEntries(TestResult result) {
        Map map = new HashMap();
        for (Enumeration e=result.errors(); e.hasMoreElements(); ) {
            TestFailure testFailure = (TestFailure) e.nextElement();
            Throwable t = testFailure.thrownException();
            String message = getRootCause(t).toString();
            ErrorSummaryEntry errorSummaryEntry = (ErrorSummaryEntry) map.get(message);
            if (errorSummaryEntry==null ) {
                errorSummaryEntry = new ErrorSummaryEntry(t);
                map.put(message, errorSummaryEntry);
View Full Code Here

    }
   
    private static Object[] getSortedArrayOfErrorSummaryEntries(TestResult result) {
        Map map = new HashMap();
        for (Enumeration e=result.errors(); e.hasMoreElements(); ) {
            TestFailure testFailure = (TestFailure) e.nextElement();
            Throwable t = testFailure.thrownException();
            String message = getRootCause(t).toString();
            ErrorSummaryEntry errorSummaryEntry = (ErrorSummaryEntry) map.get(message);
            if (errorSummaryEntry==null ) {
                errorSummaryEntry = new ErrorSummaryEntry(t);
                map.put(message, errorSummaryEntry);
View Full Code Here

     * @param theTest the test object that failed
     * @param theThrowable the exception that was thrown
     */
    public void addError(Test theTest, Throwable theThrowable)
    {
        TestFailure failure = new TestFailure(theTest, theThrowable);
        StringBuffer xml = new StringBuffer();

        xml.append("<" + ERROR + " " + ATTR_MESSAGE + "=\""
            + xmlEncode(failure.thrownException().getMessage()) + "\" "
            + ATTR_TYPE + "=\""
            + failure.thrownException().getClass().getName() + "\">");
        xml.append(xmlEncode(StringUtil.exceptionToString(
            failure.thrownException(), DEFAULT_STACK_FILTER_PATTERNS)));
        xml.append("</" + ERROR + ">");

        this.currentTestFailure = xml.toString();
    }
View Full Code Here

     * @param theTest the test object that failed
     * @param theError the exception that was thrown
     */
    public void addFailure(Test theTest, AssertionFailedError theError)
    {
        TestFailure failure = new TestFailure(theTest, theError);
        StringBuffer xml = new StringBuffer();

        xml.append("<" + FAILURE + " " + ATTR_MESSAGE + "=\""
            + xmlEncode(failure.thrownException().getMessage()) + "\" "
            + ATTR_TYPE + "=\""
            + failure.thrownException().getClass().getName() + "\">");
        xml.append(xmlEncode(StringUtil.exceptionToString(
            failure.thrownException(), DEFAULT_STACK_FILTER_PATTERNS)));
        xml.append("</" + FAILURE + ">");

        this.currentTestFailure = xml.toString();
    }
View Full Code Here

    System.out.println("Runs " + testResult.runCount() + ", Errors: "
        + testResult.errorCount());

    Enumeration e = testResult.errors();
    while (e.hasMoreElements()) {
      TestFailure f = (TestFailure) e.nextElement();
      System.out.println(f);
      System.out.println(f.exceptionMessage());
    }

    Assert.assertEquals(0, testResult.errorCount());

  }
View Full Code Here

TOP

Related Classes of junit.framework.TestFailure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.