Package junit.framework

Examples of junit.framework.TestFailure


  public void testInvalidMethod() {
    TestResult result= new TestResult();
    junit.framework.Test adapter= new JUnit4TestAdapter(InvalidMethodTest.class);
    adapter.run(result);
    assertEquals(1, result.errorCount())
    TestFailure failure= result.errors().nextElement();
    assertTrue(failure.exceptionMessage().contains("Method shouldBeStatic() should be static"));
  }
View Full Code Here


   * @param holder
   */
  public static void unpackProblems(TestResult result, OsgiTestInfoHolder holder) {
    Enumeration errors = result.errors();
    while (errors.hasMoreElements()) {
      TestFailure failure = (TestFailure) errors.nextElement();
      holder.addTestError(failure.thrownException());
    }
    Enumeration failures = result.failures();
    while (failures.hasMoreElements()) {
      TestFailure failure = (TestFailure) failures.nextElement();
      holder.addTestFailure(failure.thrownException());
    }
  }
View Full Code Here

    assertEquals("error considered failure", 0, result.failureCount());
  }

  public void testExceptionClass() throws Exception {
    executeTest("testException");
    TestFailure failure = (TestFailure) result.errors().nextElement();
    assertTrue(failure.thrownException() instanceof RuntimeException);
  }
View Full Code Here

    assertEquals("error considered failure", 0, result.failureCount());
  }

  public void testErrorClass() throws Exception {
    executeTest("testError");
    TestFailure failure = (TestFailure) result.errors().nextElement();
    assertTrue(failure.thrownException() instanceof Error);
  }
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

    } else {
      if (result.errorCount() > 0) {
        System.err.println("Errors:");
        for (Enumeration errors = result.errors(); errors
            .hasMoreElements();) {
          TestFailure error = (TestFailure) errors.nextElement();
          System.err.println(error.trace());
        }
      }
      if (result.failureCount() > 0) {
        System.err.println("Failures:");
        for (Enumeration failures = result.failures(); failures
            .hasMoreElements();) {
          TestFailure failure = (TestFailure) failures.nextElement();
          System.err.println(failure.trace());
        }
      }
      System.exit(1);
    };
  }
View Full Code Here

    for (int i= fSuiteCombo.getItemCount()-1; i > historyLength-1; i--)
      fSuiteCombo.removeItemAt(i);
  }

  private void appendFailure(Test test, Throwable t) {
    fFailures.addElement(new TestFailure(test, t));
    if (fFailures.size() == 1)
      revealFailure(test);
  }
View Full Code Here

  private void showFailureDetail(Test test) {
    if (test != null) {
      ListModel failures= getFailures();
      for (int i= 0; i < failures.getSize(); i++) {
        TestFailure failure= (TestFailure)failures.getElementAt(i);
        if (failure.failedTest() == test) {
          fFailureView.showFailure(failure);
          return;
        }
      }
    }
View Full Code Here

    int index= fFailureList.getSelectedIndex();
    if (index == -1)
      return null;
     
    ListModel model= fFailureList.getModel();
    TestFailure failure= (TestFailure)model.getElementAt(index);
    return failure.failedTest();
  }
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.