diff --git a/.idea/libraries/opentest4j.xml b/.idea/libraries/opentest4j.xml
new file mode 100644
index 000000000000..a950465a1404
--- /dev/null
+++ b/.idea/libraries/opentest4j.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant
index 846d9ee3f0b7..9b61c888ba32 100644
--- a/build/scripts/libLicenses.gant
+++ b/build/scripts/libLicenses.gant
@@ -267,6 +267,7 @@ libraryLicense(name: "NanoXML", version: "2.2.3", license: "zlib/libpng", url: "
libraryLicense(name: "nekohtml", libraryName: "nekohtml", version: "1.9.14", license: "Apache 2.0", url: "http://nekohtml.sourceforge.net/", licenseUrl: "http://apache.org/licenses/LICENSE-2.0.txt")
libraryLicense(name: "Netty", libraryName: "Netty", version: "4.1.0.Beta3", license: "Apache 2.0", url: "http://netty.io", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0")
libraryLicense(name: "Objenesis", libraryName: "objenesis-1.2.jar", version: "1.2", license: "Apache 2.0", url: "http://objenesis.org/", licenseUrl: "http://apache.org/licenses/LICENSE-2.0")
+libraryLicense(name: "opentest4j", libraryName: "opentest4j", version: "1.0.0", license: "Apache 2.0", url: "https://github.com/ota4j-team/opentest4j", licenseUrl: "http://apache.org/licenses/LICENSE-2.0")
libraryLicense(name: "pep8.py", attachedTo: "python-helpers", version: "1.6.2", license: "MIT", url: "http://pep8.readthedocs.org/")
libraryLicense(name: "PicoContainer", libraryName: "picocontainer", version: "1.2", license: "BSD", url: "http://www.picocontainer.org/", licenseUrl: "http://docs.codehaus.org/display/PICO/License")
libraryLicense(name: "plexus-archiver", libraryName: "plexus-archiver-2.4.4.jar", version: "2.4.4", license: "Apache 2.0", url: "https://github.com/codehaus-plexus/plexus-archiver", licenseUrl: "http://apache.org/licenses/LICENSE-2.0")
diff --git a/plugins/junit5_rt/junit5_rt.iml b/plugins/junit5_rt/junit5_rt.iml
index f37ea82817dd..ec639f339e82 100644
--- a/plugins/junit5_rt/junit5_rt.iml
+++ b/plugins/junit5_rt/junit5_rt.iml
@@ -10,5 +10,6 @@
+
\ No newline at end of file
diff --git a/plugins/junit5_rt/lib/opentest4j-1.0.0.jar b/plugins/junit5_rt/lib/opentest4j-1.0.0.jar
new file mode 100644
index 000000000000..7208395ee319
Binary files /dev/null and b/plugins/junit5_rt/lib/opentest4j-1.0.0.jar differ
diff --git a/plugins/junit5_rt/src/com/intellij/junit5/JUnit5TestExecutionListener.java b/plugins/junit5_rt/src/com/intellij/junit5/JUnit5TestExecutionListener.java
index b0b393be55b4..fcc78338351a 100644
--- a/plugins/junit5_rt/src/com/intellij/junit5/JUnit5TestExecutionListener.java
+++ b/plugins/junit5_rt/src/com/intellij/junit5/JUnit5TestExecutionListener.java
@@ -15,6 +15,7 @@
*/
package com.intellij.junit5;
+import com.intellij.junit4.ExpectedPatterns;
import com.intellij.rt.execution.junit.ComparisonFailureData;
import com.intellij.rt.execution.junit.MapSerializerUtil;
import org.junit.gen5.engine.TestExecutionResult;
@@ -22,6 +23,7 @@ import org.junit.gen5.engine.support.descriptor.JavaSource;
import org.junit.gen5.launcher.TestExecutionListener;
import org.junit.gen5.launcher.TestIdentifier;
import org.junit.gen5.launcher.TestPlan;
+import org.opentest4j.AssertionFailedError;
import java.io.PrintStream;
import java.io.PrintWriter;
@@ -116,7 +118,7 @@ public class JUnit5TestExecutionListener implements TestExecutionListener {
public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
final String displayName = testIdentifier.getDisplayName();
final TestExecutionResult.Status status = testExecutionResult.getStatus();
- final Optional throwableOptional = testExecutionResult.getThrowable();
+ final Throwable throwableOptional = testExecutionResult.getThrowable().orElse(null);
if (testIdentifier.isTest()) {
final long duration = System.currentTimeMillis() - myCurrentTestStart;
if (status == TestExecutionResult.Status.FAILED) {
@@ -155,7 +157,7 @@ public class JUnit5TestExecutionListener implements TestExecutionListener {
myPrintStream.println("\n##teamcity[testFinished" + idAndName(testIdentifier) + (duration > 0 ? "\' duration=\'" + Long.toString(duration) : "") + "\']");
}
- private void testFailure(Optional failure, String messageName, TestIdentifier testIdentifier, long duration) {
+ private void testFailure(Throwable ex, String messageName, TestIdentifier testIdentifier, long duration) {
final Map attrs = new HashMap<>();
attrs.put("name", testIdentifier.getDisplayName());
attrs.put("id", testIdentifier.getUniqueId().toString());
@@ -163,12 +165,20 @@ public class JUnit5TestExecutionListener implements TestExecutionListener {
attrs.put("duration", Long.toString(duration));
}
try {
- if (failure.isPresent()) {
- final Throwable ex = failure.get();
+ if (ex != null) {
final StringWriter stringWriter = new StringWriter();
final PrintWriter writer = new PrintWriter(stringWriter);
ex.printStackTrace(writer);
- ComparisonFailureData.registerSMAttributes(null, stringWriter.toString(), ex.getMessage(), attrs, ex);
+ final ComparisonFailureData failureData;
+ if (ex instanceof AssertionFailedError && ((AssertionFailedError)ex).isActualDefined() && ((AssertionFailedError)ex).isExpectedDefined()) {
+ final Object actual = ((AssertionFailedError)ex).getActual();
+ final Object expected = ((AssertionFailedError)ex).getExpected();
+ failureData = new ComparisonFailureData(expected.toString(), actual.toString());
+ }
+ else {
+ failureData = ExpectedPatterns.createExceptionNotification(ex);
+ }
+ ComparisonFailureData.registerSMAttributes(failureData, stringWriter.toString(), ex.getMessage(), attrs, ex);
}
}
finally {