Skip to content

Commit

Permalink
Merge branch 'master' into feature/optional_tags_for_modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
MaisiKoleni authored Mar 31, 2021
2 parents c541aa7 + eb782b6 commit 975e3ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ public Throwable sanitize(Throwable t, MessageTransformer messageTransformer) {
ValueWrapper actual = afe.getActual();
ThrowableInfo info = ThrowableInfo.getEssentialInfosSafeFrom(t).sanitize();
String newMessage = messageTransformer.apply(info);
AssertionFailedError newAfe = new AssertionFailedError(newMessage, sanitizeValue(expected),
sanitizeValue(actual));
AssertionFailedError newAfe;
// If both expected and actual are null, this cannot arise from assertEquals,
// and thus afe was constructed only by providing a message (and cause)
if (expected == null && actual == null)
newAfe = new AssertionFailedError(newMessage);
else
newAfe = new AssertionFailedError(newMessage, sanitizeValue(expected), sanitizeValue(actual));
SanitizationUtils.copyThrowableInfoSafe(info, newAfe);
return newAfe;
}
Expand Down
7 changes: 5 additions & 2 deletions src/test/java/de/tum/in/test/api/ExceptionFailureTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.tum.in.test.api;

import static de.tum.in.test.testutilities.CustomConditions.testFailedWith;
import static org.junit.platform.testkit.engine.EventConditions.*;
import static org.junit.platform.testkit.engine.TestExecutionResultConditions.*;

Expand Down Expand Up @@ -53,7 +52,11 @@ void test_assertJMultipleFailures() {
@TestTest
void test_assertionFailOnly() {
tests.assertThatEvents().haveExactly(1,
testFailedWith(assertionFailOnly, AssertionFailedError.class, "This test failed. Penguin."));
event(test(assertionFailOnly), finishedWithFailure(instanceOf(AssertionFailedError.class),
message("This test failed. Penguin."), new Condition<>(t -> {
var afe = (AssertionFailedError) t;
return afe.getActual() == null && afe.getExpected() == null;
}, "expected and actual are both null"))));
}

@TestTest
Expand Down

0 comments on commit 975e3ec

Please sign in to comment.