List of usage examples for junit.framework AssertionFailedError getMessage
public String getMessage()
From source file:org.nuxeo.runtime.test.Failures.java
@Override public String toString() { StringBuffer buffer = new StringBuffer(); int i = 1;//from w ww .jav a 2 s . com AssertionFailedError errors = new AssertionFailedError(); for (Failure failure : failures) { buffer.append("* Failure " + i + ": ").append(failure.getTestHeader()).append("\n") .append(failure.getTrace()).append("\n"); errors.addSuppressed(failure.getException()); i++; } if (errors.getSuppressed().length > 0) { // Log because JUnit swallows some parts of the stack trace log.debug(errors.getMessage(), errors); } return buffer.toString(); }
From source file:org.nuxeo.runtime.test.Failures.java
/** * Call {@link org.junit.Assert#fail(String)} with a nice expanded string if there are failures. It also replaces * original failure messages with a custom one if originalMessage is not {@code null}. * * @param originalMessage Message to replace if found in a failure * @param customMessage Custom message to use as replacement for originalMessage *//*from ww w . jav a 2 s .c o m*/ public void fail(String originalMessage, String customMessage) { if (failures.isEmpty()) { Assert.fail(customMessage); } StringBuffer buffer = new StringBuffer(); int i = 1; AssertionFailedError errors = new AssertionFailedError(customMessage); buffer.append(customMessage); for (Failure failure : failures) { buffer.append("\n* Failure " + i + ": "); String trace = failure.getTrace(); if (originalMessage != null && originalMessage.equals(failure.getMessage())) { trace.replaceAll(originalMessage, customMessage); } buffer.append(failure.getTestHeader()).append("\n").append(trace); errors.addSuppressed(failure.getException()); i++; } // Log because JUnit swallows some parts of the stack trace log.debug(errors.getMessage(), errors); Assert.fail(buffer.toString()); }