use of com.intellij.rt.execution.junit.ComparisonFailureData in project intellij-community by JetBrains.
the class IDEATestNGRemoteListener method onTestFailure.
public void onTestFailure(ExposedTestResult result) {
if (!myParamsMap.containsKey(result)) {
onTestStart(result);
}
Throwable ex = result.getThrowable();
String methodName = getTestMethodNameWithParams(result);
final Map<String, String> attrs = new LinkedHashMap<String, String>();
attrs.put("name", methodName);
final String failureMessage = ex != null ? ex.getMessage() : null;
if (ex != null) {
ComparisonFailureData notification;
try {
notification = TestNGExpectedPatterns.createExceptionNotification(failureMessage);
} catch (Throwable e) {
notification = null;
}
ComparisonFailureData.registerSMAttributes(notification, getTrace(ex), failureMessage, attrs, ex);
} else {
attrs.put("message", "");
}
myPrintStream.println();
myPrintStream.println(MapSerializerUtil.asString("testFailed", attrs));
onTestFinished(result);
}
use of com.intellij.rt.execution.junit.ComparisonFailureData in project intellij-community by JetBrains.
the class JUnit5TestExecutionListener method testFailure.
private void testFailure(String methodName, String id, String messageName, Throwable ex, long duration, String reason, boolean includeThrowable) {
final Map<String, String> attrs = new LinkedHashMap<>();
attrs.put("name", methodName);
attrs.put("id", id);
if (duration > 0) {
attrs.put("duration", Long.toString(duration));
}
if (reason != null) {
attrs.put("message", reason);
}
try {
if (ex != null) {
ComparisonFailureData failureData = null;
if (ex instanceof MultipleFailuresError && ((MultipleFailuresError) ex).hasFailures()) {
for (AssertionError assertionError : ((MultipleFailuresError) ex).getFailures()) {
testFailure(methodName, id, messageName, assertionError, duration, reason, false);
}
} else if (ex instanceof AssertionFailedError && ((AssertionFailedError) ex).isActualDefined() && ((AssertionFailedError) ex).isExpectedDefined()) {
final ValueWrapper actual = ((AssertionFailedError) ex).getActual();
final ValueWrapper expected = ((AssertionFailedError) ex).getExpected();
failureData = new ComparisonFailureData(expected.getStringRepresentation(), actual.getStringRepresentation());
} else {
//try to detect failure with junit 4 if present in the classpath
try {
failureData = ExpectedPatterns.createExceptionNotification(ex);
} catch (Throwable ignore) {
}
}
if (includeThrowable || failureData == null) {
ComparisonFailureData.registerSMAttributes(failureData, getTrace(ex), ex.getMessage(), attrs, ex, "Comparison Failure: ", "expected: <");
} else {
ComparisonFailureData.registerSMAttributes(failureData, "", "", attrs, ex, "", "expected: <");
}
}
} finally {
myPrintStream.println("\n" + MapSerializerUtil.asString(messageName, attrs));
}
}
Aggregations