From fff48ca7348b3450f32898931016f950e6f6ddd3 Mon Sep 17 00:00:00 2001 From: Stefano Cordio Date: Sun, 7 Feb 2021 11:06:13 +0100 Subject: [PATCH] Fix IntelliJ flaky test due to JUnit upgrade to version 5.7 --- ...dRepresentation_throwable_format_Test.java | 31 +++++++++++-------- verify.bndrun | 10 +++--- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/test/java/org/assertj/core/presentation/StandardRepresentation_throwable_format_Test.java b/src/test/java/org/assertj/core/presentation/StandardRepresentation_throwable_format_Test.java index 7e85a0ac2a..a542f3f81a 100644 --- a/src/test/java/org/assertj/core/presentation/StandardRepresentation_throwable_format_Test.java +++ b/src/test/java/org/assertj/core/presentation/StandardRepresentation_throwable_format_Test.java @@ -13,8 +13,8 @@ package org.assertj.core.presentation; import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.catchThrowable; +import static org.assertj.core.api.BDDAssertions.then; import org.assertj.core.configuration.Configuration; import org.junit.jupiter.api.Test; @@ -25,6 +25,7 @@ * @author XiaoMingZHM Eveneko */ class StandardRepresentation_throwable_format_Test { + private static final Representation REPRESENTATION = new StandardRepresentation(); // Just to make sure the stack trace is long enough. @@ -48,9 +49,9 @@ void should_not_display_stacktrace_if_maxStackTraceElementsDisplayed_is_zero() { configuration.setMaxStackTraceElementsDisplayed(0); configuration.apply(); // WHEN - String toString = REPRESENTATION.toStringOf(catchThrowable(() -> Test1.boom())); + String toString = REPRESENTATION.toStringOf(catchThrowable(Test1::boom)); // THEN - assertThat(toString).isEqualTo("java.lang.RuntimeException"); + then(toString).isEqualTo("java.lang.RuntimeException"); } @Test @@ -60,13 +61,17 @@ void should_display_the_configured_number_of_stacktrace_elements() { // configuration.setMaxStackTraceElementsDisplayed(3); configuration.apply(); // WHEN - String toString = REPRESENTATION.toStringOf(catchThrowable(() -> Test1.boom())); + String toString = REPRESENTATION.toStringOf(catchThrowable(Test1::boom)); // THEN - assertThat(toString).containsSubsequence(format("java.lang.RuntimeException%n"), - format("\tat org.assertj.core.presentation.StandardRepresentation_throwable_format_Test$Test1$Test2.boom2(StandardRepresentation_throwable_format_Test.java:"), - format("\tat org.assertj.core.presentation.StandardRepresentation_throwable_format_Test$Test1.boom(StandardRepresentation_throwable_format_Test.java"), - format("\tat org.assertj.core.presentation.StandardRepresentation_throwable_format_Test.lambda"), - format("\t...(71 remaining lines not displayed - this can be changed with Assertions.setMaxStackTraceElementsDisplayed)")); + then(toString).matches("java\\.lang\\.RuntimeException\\R" + + + "\\tat org\\.assertj\\.core\\.presentation\\.StandardRepresentation_throwable_format_Test\\$Test1\\$Test2\\.boom2\\(StandardRepresentation_throwable_format_Test\\.java:36\\)\\R" + + + "\\tat org\\.assertj\\.core\\.presentation\\.StandardRepresentation_throwable_format_Test\\$Test1\\.boom\\(StandardRepresentation_throwable_format_Test\\.java:41\\)\\R" + + + "\\tat org\\.assertj\\.core\\.api\\.ThrowableAssert\\.catchThrowable\\(ThrowableAssert\\.java:62\\)\\R" + + + "\\t\\.{3}\\(\\d+ remaining lines not displayed - this can be changed with Assertions\\.setMaxStackTraceElementsDisplayed\\)"); } @Test @@ -76,11 +81,11 @@ void should_display_the_full_stacktrace() { configuration.setMaxStackTraceElementsDisplayed(100); configuration.apply(); // WHEN - String toString = REPRESENTATION.toStringOf(catchThrowable(() -> Test1.boom())); + String toString = REPRESENTATION.toStringOf(catchThrowable(Test1::boom)); // THEN - assertThat(toString).startsWith(format("java.lang.RuntimeException%n" - + "\tat org.assertj.core.presentation.StandardRepresentation_throwable_format_Test$Test1$Test2.boom2(StandardRepresentation_throwable_format_Test.java")) - .doesNotContain("remaining lines not displayed"); + then(toString).startsWith(format("java.lang.RuntimeException%n" + + "\tat org.assertj.core.presentation.StandardRepresentation_throwable_format_Test$Test1$Test2.boom2(StandardRepresentation_throwable_format_Test.java")) + .doesNotContain("remaining lines not displayed"); } } diff --git a/verify.bndrun b/verify.bndrun index 292e6ba959..33c92e1fe4 100644 --- a/verify.bndrun +++ b/verify.bndrun @@ -32,9 +32,9 @@ -runbundles: \ assertj-core;version='[3.19.1,3.19.2)',\ assertj-core-tests;version='[3.19.1,3.19.2)',\ - junit-jupiter-api;version='[5.6.3,5.6.4)',\ - junit-jupiter-engine;version='[5.6.3,5.6.4)',\ - junit-platform-commons;version='[1.6.3,1.6.4)',\ - junit-platform-engine;version='[1.6.3,1.6.4)',\ - junit-platform-launcher;version='[1.6.3,1.6.4)',\ + junit-jupiter-api;version='[5.7.1,5.7.2)',\ + junit-jupiter-engine;version='[5.7.1,5.7.2)',\ + junit-platform-commons;version='[1.7.1,1.7.2)',\ + junit-platform-engine;version='[1.7.1,1.7.2)',\ + junit-platform-launcher;version='[1.7.1,1.7.2)',\ org.opentest4j;version='[1.2.0,1.2.1)'