Package junit.framework

Examples of junit.framework.TestFailure


        return 1;
      }

      @Override
      public List<TestFailure> getErrors() {
        return Arrays.asList(new TestFailure[] { new TestFailure(
          null,
          new Exception()) });
      }
    };
View Full Code Here


        return 0;
      }

      @Override
      public List<TestFailure> getFailures() {
        return Arrays.asList(new TestFailure[] { new TestFailure(
          null,
          new AssertionFailedError()) });
      }
    };
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.printf("Run %d , Fail %d , Error %d \n", result.runCount(), result.failureCount(), result.errorCount());
       
        if (result.failureCount() > 0) {
            Enumeration<TestFailure> enu = result.failures();
            while (enu.hasMoreElements()) {
                TestFailure testFailure = (TestFailure) enu.nextElement();
                System.out.println("--Fail------------------------------------------------");
                System.out.println(testFailure.trace());
                testFailure.thrownException().printStackTrace(System.out);
            }
        }
       
        if (result.errorCount() > 0) {
            Enumeration<TestFailure> enu = result.errors();
            while (enu.hasMoreElements()) {
                TestFailure testFailure = (TestFailure) enu.nextElement();
                System.out.println("--ERROR------------------------------------------------");
                System.out.println(testFailure.trace());
                testFailure.thrownException().printStackTrace(System.out);
            }
        }
    }
View Full Code Here

                testRunnerState.setTestProp(testName, "status", "PASSED");
            } else {
                testRunnerState.setTestProp(testName, "status", "FAILED");
                StringBuffer res = new StringBuffer("Failures:\n");
                for (Enumeration<TestFailure> fs = result.failures(); fs.hasMoreElements();) {
                    TestFailure f = fs.nextElement();
                    testRunnerState.setTestProp(testName, "exception", "Failure\n" + f.trace());
                    f.exceptionMessage();
                    res.append(f.exceptionMessage()).append("\n");
                }
                res.append("Errors:\n");
                for (Enumeration<TestFailure> fs = result.errors(); fs.hasMoreElements();) {
                    TestFailure f = fs.nextElement();
                    testRunnerState.setTestProp(testName, "exception", "Error\n" + f.trace());
                    res.append(f.exceptionMessage()).append("\n");
                }
                System.out.println(res.toString());
            }
            return result;
        }
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

            else
                userLog().info("There were "+testResult.errorCount()+" errors:");

            int i= 1;
            for (Enumeration e= testResult.errors(); e.hasMoreElements(); i++) {
                TestFailure failure= (TestFailure)e.nextElement();
                userLog().info(i + ") " + failure.failedTest());
                userLog().info(BaseTestRunner.getFilteredTrace(failure.thrownException()));
            }
        }
    }
View Full Code Here

                userLog().info("There was " + testResult.failureCount() + " failure:");
            else
                userLog().info("There were " + testResult.failureCount() + " failures:");
            int i = 1;
            for (Enumeration e= testResult.failures(); e.hasMoreElements(); i++) {
                TestFailure failure= (TestFailure) e.nextElement();
                userLog().info(i + ") " + failure.failedTest());
                userLog().info(BaseTestRunner.getFilteredTrace(failure.thrownException()));
            }
        }
    }
View Full Code Here

        int failureCount = r.failureCount();
        System.out.println((runCount - failureCount) + "/" + runCount + " tests succeeded!");
        if (!r.wasSuccessful()) {
            Enumeration en = r.errors();
            while (en.hasMoreElements()) {
                TestFailure tf = (TestFailure) en.nextElement();
                System.out.println(tf.toString());
            }

            en = r.failures();
            while (en.hasMoreElements()) {
                TestFailure tf = (TestFailure) en.nextElement();
                System.out.println(tf.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.