mas01mj@732: package asunit.framework { mas01mj@732: import asunit.errors.AssertionFailedError; mas01mj@732: mas01mj@732: /** mas01mj@732: * A TestFailure collects a failed test together with mas01mj@732: * the caught exception. mas01mj@732: * @see TestResult mas01mj@732: */ mas01mj@732: public class TestFailure { mas01mj@732: protected var fFailedTest:Test; mas01mj@732: protected var fFailedTestMethod:String; mas01mj@732: protected var fThrownException:Error; mas01mj@732: mas01mj@732: /** mas01mj@732: * Constructs a TestFailure with the given test and exception. mas01mj@732: */ mas01mj@732: public function TestFailure(failedTest:Test, thrownException:Error) { mas01mj@732: fFailedTest = failedTest; mas01mj@732: fFailedTestMethod = failedTest.getCurrentMethod(); mas01mj@732: fThrownException = thrownException; mas01mj@732: } mas01mj@732: mas01mj@732: public function failedFeature():String { mas01mj@732: return failedTest().getName() + '.' + fFailedTestMethod; mas01mj@732: } mas01mj@732: mas01mj@732: public function failedMethod():String { mas01mj@732: return fFailedTestMethod; mas01mj@732: } mas01mj@732: mas01mj@732: /** mas01mj@732: * Gets the failed test case. mas01mj@732: */ mas01mj@732: public function failedTest():Test { mas01mj@732: return fFailedTest; mas01mj@732: } mas01mj@732: /** mas01mj@732: * Gets the thrown exception. mas01mj@732: */ mas01mj@732: public function thrownException():Error { mas01mj@732: return fThrownException; mas01mj@732: } mas01mj@732: /** mas01mj@732: * Returns a short description of the failure. mas01mj@732: */ mas01mj@732: public function toString():String { mas01mj@732: return ""; mas01mj@732: } mas01mj@732: mas01mj@732: public function exceptionMessage():String { mas01mj@732: return thrownException().message; mas01mj@732: } mas01mj@732: mas01mj@732: public function isFailure():Boolean { mas01mj@732: return thrownException() is AssertionFailedError; mas01mj@732: } mas01mj@732: } mas01mj@732: }