📄 testfailure.java
字号:
package momeunit.framework;/** * Describes a test failure or error. There are two kinds of test failures: * <ul> * <li> <strong>failure</strong> - anticipated error checked with assertions.</li> * <li> <strong>error</strong> - unanticipated error thrown while executing the * test. * </ul> * This class represents an association of test and exception (either * {@link AssertionFailedError} thrown as result of test failure, or * {@link Throwable} thrown while executing this test). Contains methods for * checking the kind of failure and printing the stack-trace of thrown * exception. * * @see TestResult * * @author Sergio Morozov * @version 1.1.2 */public class TestFailure extends Object{ /** * Test instance that failed. * * @since 1.0 */ protected Test test; /** * Throwable thrown while executing test. * * @since 1.0 */ protected Throwable problem; /** * Instantiates a TestFailure with the given {@link Test} and * {@link Throwable}. * * @param failedTest * test that failed. * @param thrownException * Throwable thrown while executing test. * @since 1.0 */ public TestFailure(Test failedTest, Throwable thrownException) { this.test = failedTest; this.problem = thrownException; } /** * Returns the failed test. * * @return failed test. * @since 1.0 */ public Test failedTest() { return test; } /** * Returns the thrown exception. * * @return thrown exception. * @since 1.0 */ public Throwable thrownException() { return problem; } /** * Checks is this TestFailure a result of failed assertion or thrown error. * * @return true if this TestFailure is a result of failed assertion, false * otherwise. * @since 1.0 */ public boolean isFailure() { return thrownException() instanceof AssertionFailedError; } /** * Returns a short description of this TestFailure. * * @return short description of this TestFailure. * @see java.lang.Object#toString() * @since 1.0 */ public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append(test + ": " + problem.getMessage()); return buffer.toString(); } /** * Prints stack-trace of thrown exception to the standard error output. * * @since 1.0 */ public void printTrace() { this.problem.printStackTrace(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -