Package junit.framework

Examples of junit.framework.TestFailure


                System.out.println("\nFailed tests:");
                for (int i = 0; i < m_failures.size(); i++) {
                    TestResult tr = (TestResult) m_failures.get(i);
                    Enumeration e = tr.failures();
                    while (e.hasMoreElements()) {
                        TestFailure tf = (TestFailure) e.nextElement();
                        System.out.println(" " + tf.toString());
                    }
                }
            }
           
            if (m_failures.size() > 0) {
                System.out.println("\nTests in error:");
                for (int i = 0; i < m_errors.size(); i++) {
                    TestResult tr = (TestResult) m_errors.get(i);
                    Enumeration e = tr.errors();
                    while (e.hasMoreElements()) {
                        TestFailure tf = (TestFailure) e.nextElement();
                        System.out.println(" " + tf.toString());
                    }
                }
            }
           
            System.out.println("\nTests run: " + m_total + ", Failures: " + m_totalFailures + ", Errors:" + m_totalErrors + "\n");         
View Full Code Here


                System.out.println("\nFailed tests:");
                for (int i = 0; i < m_failures.size(); i++) {
                    TestResult tr = (TestResult) m_failures.get(i);
                    Enumeration e = tr.failures();
                    while (e.hasMoreElements()) {
                        TestFailure tf = (TestFailure) e.nextElement();
                        System.out.println(" " + tf.toString());
                    }
                }
            }

            if (m_failures.size() > 0) {
                System.out.println("\nTests in error:");
                for (int i = 0; i < m_errors.size(); i++) {
                    TestResult tr = (TestResult) m_errors.get(i);
                    Enumeration e = tr.errors();
                    while (e.hasMoreElements()) {
                        TestFailure tf = (TestFailure) e.nextElement();
                        System.out.println(" " + tf.toString());
                    }
                }
            }

            System.out.println("\nTests run: " + m_total + ", Failures: " + m_totalFailures + ", Errors:" + m_totalErrors + "\n");
View Full Code Here

        private void displayProblems( PrintWriter writer, String title, int count, Enumeration enumeration ) {
            if (count != 0) {
                writer.println( "<tr><td colspan=3>" + getFormatted( count, title ) + "</td></tr>" );
                Enumeration e = enumeration;
                for (int i = 1; e.hasMoreElements(); i++) {
                    TestFailure failure = (TestFailure) e.nextElement();
                    writer.println( "<tr><td class='detail' align='right'>" + i + "</td>" );
                    writer.println( "<td class='detail'>" + failure.failedTest() + "</td><td class='detail'>" );
                    if (failure.thrownException() instanceof AssertionFailedError) {
                        writer.println( htmlEscape( failure.thrownException().getMessage() ) );
                    } else {
                        writer.println( htmlEscape( getFilteredTrace( failure.thrownException() ) ) );
                    }
                    writer.println( "</td></tr>" );
                }
            }
        }
View Full Code Here

        private void displayProblems( PrintWriter writer, String title, int count, Enumeration enumeration ) {
            if (count != 0) {
                writer.println( "<tr><td colspan=3>" + getFormatted( count, title ) + "</td></tr>" );
                Enumeration e = enumeration;
                for (int i = 1; e.hasMoreElements(); i++) {
                    TestFailure failure = (TestFailure) e.nextElement();
                    writer.println( "<tr><td class='detail' align='right'>" + i + "</td>" );
                    writer.println( "<td class='detail'>" + failure.failedTest() + "</td><td class='detail'>" );
                    if (failure.thrownException() instanceof AssertionFailedError) {
                        writer.println( htmlEscape( failure.thrownException().getMessage() ) );
                    } else {
                        writer.println( htmlEscape( getFilteredTrace( failure.thrownException() ) ) );
                    }
                    writer.println( "</td></tr>" );
                }
            }
        }
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())));
        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

     * @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

                fail("Security test was expected to run successfully, but failed (results on System.out)");
            } else {
                //There may be more than 1 failure:  iterate to ensure that they all match the missingPermission.
                boolean otherFailure = false;
                for (Enumeration e = result.errors(); e.hasMoreElements();) {
                    TestFailure failure = (TestFailure) e.nextElement();
                    if (failure.thrownException() instanceof AccessControlException) {
                        AccessControlException ace = (AccessControlException) failure.thrownException();
                        if (missingPermission.implies(ace.getPermission())) {
                            continue;
                        }
                    }
                    otherFailure = true;
View Full Code Here

    }

    private String createFailureMessage(TestResult result) {
        StringBuffer failureMessage = new StringBuffer();
        for (Enumeration errors = result.errors(); errors.hasMoreElements();) {
            TestFailure error = (TestFailure) errors.nextElement();
            failureMessage.append(error.trace());
        }
        return failureMessage.toString();
    }
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.