Skip to content

Commit 36bb005

Browse files
sbrannenmarcphilipp
authored andcommitted
Improve assertion failure message in TestClassPredicatesTests
The recursiveHierarchies() test currently fails when running in Eclipse IDE, but the failure message does not indicate what the expected message is for the expected JUnitException. This commit therefore updates the assertion to check the exception message to help with diagnostics. (cherry picked from commit 3c5b457)
1 parent 2c86dfa commit 36bb005

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

jupiter-tests/src/test/java/org/junit/jupiter/engine/discovery/predicates/TestClassPredicatesTests.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
package org.junit.jupiter.engine.discovery.predicates;
1212

1313
import static org.assertj.core.api.Assertions.assertThat;
14+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
1415
import static org.junit.jupiter.api.Assertions.assertFalse;
15-
import static org.junit.jupiter.api.Assertions.assertThrows;
1616
import static org.junit.jupiter.api.Assertions.assertTrue;
1717

1818
import java.util.ArrayList;
@@ -218,7 +218,11 @@ void privateStaticTestClassEvaluatesToFalse() {
218218
*/
219219
@Test
220220
void recursiveHierarchies() {
221-
assertThrows(JUnitException.class, () -> predicates.looksLikeIntendedTestClass(TestCases.OuterClass.class));
221+
assertThatExceptionOfType(JUnitException.class)//
222+
.isThrownBy(() -> predicates.looksLikeIntendedTestClass(TestCases.OuterClass.class))//
223+
.withMessage("Detected cycle in inner class hierarchy between %s and %s",
224+
TestCases.OuterClass.RecursiveInnerClass.class.getName(), TestCases.OuterClass.class.getName());
225+
222226
assertTrue(predicates.isValidStandaloneTestClass(TestCases.OuterClass.class));
223227
assertThat(discoveryIssues).isEmpty();
224228

@@ -404,6 +408,7 @@ void test() {
404408
@SuppressWarnings("InnerClassMayBeStatic")
405409
class RecursiveInnerClass extends OuterClass {
406410
}
411+
407412
}
408413

409414
private static class NestedClassesTestCase {

0 commit comments

Comments
 (0)