File tree Expand file tree Collapse file tree 5 files changed +19
-10
lines changed
documentation/src/docs/asciidoc/release-notes
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/discovery
jupiter-tests/src/test/java/org/junit/jupiter/engine/extension Expand file tree Collapse file tree 5 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ repository on GitHub.
5959 that both `null` and _blank_ values are supported for reason strings and that such
6060 values will result in an _empty_ `Optional` returned from
6161 `ConditionEvaluationResult.getReason()`.
62+ * Improve message of discovery issues reported for ineffective `@Order` annotations.
6263
6364
6465[[release-notes-5.13.3-junit-vintage]]
Original file line number Diff line number Diff line change 2828import org .junit .platform .engine .DiscoveryIssue ;
2929import org .junit .platform .engine .DiscoveryIssue .Severity ;
3030import org .junit .platform .engine .TestDescriptor ;
31- import org .junit .platform .engine .support .descriptor .ClassSource ;
3231import org .junit .platform .engine .support .discovery .DiscoveryIssueReporter ;
3332import org .junit .platform .engine .support .discovery .DiscoveryIssueReporter .Condition ;
3433
@@ -49,10 +48,13 @@ class ClassOrderingVisitor extends AbstractOrderingVisitor {
4948 this .globalOrderer = createGlobalOrderer (configuration );
5049 this .noOrderAnnotation = issueReporter .createReportingCondition (
5150 testDescriptor -> !isAnnotated (testDescriptor .getTestClass (), Order .class ), testDescriptor -> {
52- String message = "Ineffective @Order annotation on class '%s'. It will not be applied because ClassOrderer.OrderAnnotation is not in use." .formatted (
53- testDescriptor .getTestClass ().getName ());
51+ String message = """
52+ Ineffective @Order annotation on class '%s'. \
53+ It will not be applied because ClassOrderer.OrderAnnotation is not in use. \
54+ Note that the annotation may be either directly present or meta-present on the class.""" //
55+ .formatted (testDescriptor .getTestClass ().getName ());
5456 return DiscoveryIssue .builder (Severity .INFO , message ) //
55- .source (ClassSource . from ( testDescriptor .getTestClass () )) //
57+ .source (testDescriptor .getSource ( )) //
5658 .build ();
5759 });
5860 }
Original file line number Diff line number Diff line change 3030import org .junit .platform .engine .DiscoveryIssue ;
3131import org .junit .platform .engine .DiscoveryIssue .Severity ;
3232import org .junit .platform .engine .TestDescriptor ;
33- import org .junit .platform .engine .support .descriptor .MethodSource ;
3433import org .junit .platform .engine .support .discovery .DiscoveryIssueReporter ;
3534import org .junit .platform .engine .support .discovery .DiscoveryIssueReporter .Condition ;
3635
@@ -50,10 +49,13 @@ class MethodOrderingVisitor extends AbstractOrderingVisitor {
5049 this .configuration = configuration ;
5150 this .noOrderAnnotation = issueReporter .createReportingCondition (
5251 testDescriptor -> !isAnnotated (testDescriptor .getTestMethod (), Order .class ), testDescriptor -> {
53- String message = "Ineffective @Order annotation on method '%s'. It will not be applied because MethodOrderer.OrderAnnotation is not in use." .formatted (
54- testDescriptor .getTestMethod ().toGenericString ());
52+ String message = """
53+ Ineffective @Order annotation on method '%s'. \
54+ It will not be applied because MethodOrderer.OrderAnnotation is not in use. \
55+ Note that the annotation may be either directly present or meta-present on the method.""" //
56+ .formatted (testDescriptor .getTestMethod ().toGenericString ());
5557 return DiscoveryIssue .builder (Severity .INFO , message ) //
56- .source (MethodSource . from ( testDescriptor .getTestMethod () )) //
58+ .source (testDescriptor .getSource ( )) //
5759 .build ();
5860 });
5961 this .methodsBeforeNestedClassesOrderer = createMethodsBeforeNestedClassesOrderer ();
Original file line number Diff line number Diff line change @@ -205,7 +205,9 @@ private static void assertIneffectiveOrderAnnotationIssues(List<DiscoveryIssue>
205205 assertThat (discoveryIssues ).extracting (DiscoveryIssue ::severity ).containsOnly (Severity .INFO );
206206 assertThat (discoveryIssues ).extracting (DiscoveryIssue ::message ) //
207207 .allMatch (it -> it .startsWith ("Ineffective @Order annotation on class" )
208- && it .endsWith ("It will not be applied because ClassOrderer.OrderAnnotation is not in use." ));
208+ && it .contains ("It will not be applied because ClassOrderer.OrderAnnotation is not in use." )
209+ && it .endsWith (
210+ "Note that the annotation may be either directly present or meta-present on the class." ));
209211 assertThat (discoveryIssues ).extracting (DiscoveryIssue ::source ).extracting (Optional ::orElseThrow ) //
210212 .containsExactlyInAnyOrder (ClassSource .from (A_TestCase .class ), ClassSource .from (C_TestCase .class ));
211213 }
Original file line number Diff line number Diff line change @@ -374,7 +374,9 @@ private static void assertIneffectiveOrderAnnotationIssues(List<DiscoveryIssue>
374374 assertThat (discoveryIssues ).extracting (DiscoveryIssue ::severity ).containsOnly (Severity .INFO );
375375 assertThat (discoveryIssues ).extracting (DiscoveryIssue ::message ) //
376376 .allMatch (it -> it .startsWith ("Ineffective @Order annotation on method" )
377- && it .endsWith ("It will not be applied because MethodOrderer.OrderAnnotation is not in use." ));
377+ && it .contains ("It will not be applied because MethodOrderer.OrderAnnotation is not in use." )
378+ && it .endsWith (
379+ "Note that the annotation may be either directly present or meta-present on the method." ));
378380 var testClass = WithoutTestMethodOrderTestCase .class ;
379381 assertThat (discoveryIssues ).extracting (DiscoveryIssue ::source ).extracting (Optional ::orElseThrow ) //
380382 .containsExactlyInAnyOrder (MethodSource .from (testClass .getDeclaredMethod ("test1" )),
You can’t perform that action at this time.
0 commit comments