AssertionFailedError afe = new AssertionFailedError(thrown.toString()); afe.setStackTrace(thrown.getStackTrace()); throw afe;
/** * Clones the test result from a TestResult loaded through a different * classloader. * * @param source test result loaded through a different classloader * @param destination test result reported to the outside framework * @param test initial test used for bootstrapping the integration framework * @return cloned test result */ public static TestResult cloneTestResults(OsgiTestInfoHolder source, TestResult destination, Test test) { // get errors for (Iterator iter = source.getTestErrors().iterator(); iter.hasNext();) { destination.addError(test, (Throwable) iter.next()); } // get failures // since failures are a special JUnit error, we have to clone the stack for (Iterator iter = source.getTestFailures().iterator(); iter.hasNext();) { Throwable originalFailure = (Throwable) iter.next(); AssertionFailedError clonedFailure = new AssertionFailedError(originalFailure.getMessage()); clonedFailure.setStackTrace(originalFailure.getStackTrace()); destination.addFailure(test, clonedFailure); } return destination; }
@Override public void addError(final Test test, final Throwable t) { if (junit4 && t instanceof AssertionFailedError) { // JUnit 4 does not distinguish between errors and failures // even in the JUnit 3 adapter. // So we need to help it a bit to retain compatibility for JUnit 3 tests. testListener.addFailure(test, (AssertionFailedError) t); } else if (junit4 && t instanceof AssertionError) { // Not strictly necessary but probably desirable. // JUnit 4-specific test GUIs will show just "failures". // But Ant's output shows "failures" vs. "errors". // We would prefer to show "failure" for things that logically are. final String msg = t.getMessage(); final AssertionFailedError failure = msg != null ? new AssertionFailedError(msg) : new AssertionFailedError(); failure.initCause(t.getCause()); failure.setStackTrace(t.getStackTrace()); testListener.addFailure(test, failure); } else { testListener.addError(test, t); } } @Override
ne.initCause(ex.getCause()); ne.setStackTrace (ex.getStackTrace ()); return ne;
private AssertionFailedError toAssertionFailedError(SerializableThrowable thrown) { AssertionFailedError error = new AssertionFailedError(thrown.getMessage()); error.setStackTrace(thrown.getStackTrace()); if (thrown.getCause() != null) { error.initCause(thrown.getCause()); } return error; }
private AssertionFailedError toAssertionFailedError(SerializableThrowable thrown) { AssertionFailedError error = new AssertionFailedError(thrown.getMessage()); error.setStackTrace(thrown.getStackTrace()); if (thrown.getCause() != null) { error.initCause(thrown.getCause()); } return error; }
afe.setStackTrace(cause.getStackTrace()); tr.addFailure(theClazz, afe); } else if (cause != null) {