git clone of logicmail with some fixes/features added
at master 77 lines 2.4 kB view raw
1//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2// This file is part of J2MEUnit, a Java 2 Micro Edition unit testing framework. 3// 4// J2MEUnit is free software distributed under the Common Public License (CPL). 5// It may be redistributed and/or modified under the terms of the CPL. You 6// should have received a copy of the license along with J2MEUnit. It is also 7// available from the website of the Open Source Initiative at 8// http://www.opensource.org. 9// 10// J2MEUnit is distributed in the hope that it will be useful, but WITHOUT ANY 11// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12// FOR A PARTICULAR PURPOSE. 13//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 14package j2meunit.framework; 15 16/******************************************************************** 17 * A <code>TestFailure</code> collects a failed test together with the caught 18 * exception. 19 * 20 * @see TestResult 21 */ 22public class TestFailure extends Object 23{ 24 //~ Instance fields -------------------------------------------------------- 25 26 protected Test fFailedTest; 27 protected Throwable fThrownException; 28 29 //~ Constructors ----------------------------------------------------------- 30 31 /*************************************** 32 * Constructs a TestFailure with the given test and exception. 33 * 34 * @param failedTest The failed test 35 * @param thrownException The causing exception 36 */ 37 public TestFailure(Test failedTest, Throwable thrownException) 38 { 39 fFailedTest = failedTest; 40 fThrownException = thrownException; 41 } 42 43 //~ Methods ---------------------------------------------------------------- 44 45 /*************************************** 46 * Gets the failed test. 47 * 48 * @return The failed test 49 */ 50 public Test failedTest() 51 { 52 return fFailedTest; 53 } 54 55 /*************************************** 56 * Gets the thrown exception. 57 * 58 * @return The exception causing the failure 59 */ 60 public Throwable thrownException() 61 { 62 return fThrownException; 63 } 64 65 /*************************************** 66 * Returns a short description of the failure. 67 * 68 * @return A string describing the failure 69 */ 70 public String toString() 71 { 72 StringBuffer buffer = new StringBuffer(); 73 buffer.append(fFailedTest + ": " + fThrownException.getMessage()); 74 75 return buffer.toString(); 76 } 77}