Skip to content

Commit 6a61bfc

Browse files
PascalSchumacherjoel-costigliola
authored andcommitted
Make dependency on OpenTest4J optional again (fixes assertj#1563).
1 parent f58a64e commit 6a61bfc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/org/assertj/core/error/AssertionErrorCreator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ private Optional<AssertionError> tryBuildingMultipleFailuresError(String heading
109109
if (multipleFailuresError instanceof AssertionError) { // means that we were able to build a MultipleFailuresError
110110
List<Throwable> failures = extractFailuresOf(multipleFailuresError);
111111
// we switch to AssertJMultipleFailuresError in order to control the formatting of the error message.
112-
AssertionError assertionError = new AssertJMultipleFailuresError(heading, failures);
112+
// we use reflection to avoid making opentest4j a required dependency
113+
AssertionError assertionError = (AssertionError) constructorInvoker.newInstance("org.assertj.core.error.AssertJMultipleFailuresError",
114+
MULTIPLE_FAILURES_ERROR_ARGUMENT_TYPES,
115+
array(heading, failures));
113116
Failures.instance().removeAssertJRelatedElementsFromStackTraceIfNeeded(assertionError);
114117
return Optional.of(assertionError);
115118
}

0 commit comments

Comments
 (0)