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.
59
59
that both `null` and _blank_ values are supported for reason strings and that such
60
60
values will result in an _empty_ `Optional` returned from
61
61
`ConditionEvaluationResult.getReason()`.
62
+ * Improve message of discovery issues reported for ineffective `@Order` annotations.
62
63
63
64
64
65
[[release-notes-5.13.3-junit-vintage]]
Original file line number Diff line number Diff line change 28
28
import org .junit .platform .engine .DiscoveryIssue ;
29
29
import org .junit .platform .engine .DiscoveryIssue .Severity ;
30
30
import org .junit .platform .engine .TestDescriptor ;
31
- import org .junit .platform .engine .support .descriptor .ClassSource ;
32
31
import org .junit .platform .engine .support .discovery .DiscoveryIssueReporter ;
33
32
import org .junit .platform .engine .support .discovery .DiscoveryIssueReporter .Condition ;
34
33
@@ -49,10 +48,13 @@ class ClassOrderingVisitor extends AbstractOrderingVisitor {
49
48
this .globalOrderer = createGlobalOrderer (configuration );
50
49
this .noOrderAnnotation = issueReporter .createReportingCondition (
51
50
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 ());
54
56
return DiscoveryIssue .builder (Severity .INFO , message ) //
55
- .source (ClassSource . from ( testDescriptor .getTestClass () )) //
57
+ .source (testDescriptor .getSource ( )) //
56
58
.build ();
57
59
});
58
60
}
Original file line number Diff line number Diff line change 30
30
import org .junit .platform .engine .DiscoveryIssue ;
31
31
import org .junit .platform .engine .DiscoveryIssue .Severity ;
32
32
import org .junit .platform .engine .TestDescriptor ;
33
- import org .junit .platform .engine .support .descriptor .MethodSource ;
34
33
import org .junit .platform .engine .support .discovery .DiscoveryIssueReporter ;
35
34
import org .junit .platform .engine .support .discovery .DiscoveryIssueReporter .Condition ;
36
35
@@ -50,10 +49,13 @@ class MethodOrderingVisitor extends AbstractOrderingVisitor {
50
49
this .configuration = configuration ;
51
50
this .noOrderAnnotation = issueReporter .createReportingCondition (
52
51
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 ());
55
57
return DiscoveryIssue .builder (Severity .INFO , message ) //
56
- .source (MethodSource . from ( testDescriptor .getTestMethod () )) //
58
+ .source (testDescriptor .getSource ( )) //
57
59
.build ();
58
60
});
59
61
this .methodsBeforeNestedClassesOrderer = createMethodsBeforeNestedClassesOrderer ();
Original file line number Diff line number Diff line change @@ -205,7 +205,9 @@ private static void assertIneffectiveOrderAnnotationIssues(List<DiscoveryIssue>
205
205
assertThat (discoveryIssues ).extracting (DiscoveryIssue ::severity ).containsOnly (Severity .INFO );
206
206
assertThat (discoveryIssues ).extracting (DiscoveryIssue ::message ) //
207
207
.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." ));
209
211
assertThat (discoveryIssues ).extracting (DiscoveryIssue ::source ).extracting (Optional ::orElseThrow ) //
210
212
.containsExactlyInAnyOrder (ClassSource .from (A_TestCase .class ), ClassSource .from (C_TestCase .class ));
211
213
}
Original file line number Diff line number Diff line change @@ -374,7 +374,9 @@ private static void assertIneffectiveOrderAnnotationIssues(List<DiscoveryIssue>
374
374
assertThat (discoveryIssues ).extracting (DiscoveryIssue ::severity ).containsOnly (Severity .INFO );
375
375
assertThat (discoveryIssues ).extracting (DiscoveryIssue ::message ) //
376
376
.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." ));
378
380
var testClass = WithoutTestMethodOrderTestCase .class ;
379
381
assertThat (discoveryIssues ).extracting (DiscoveryIssue ::source ).extracting (Optional ::orElseThrow ) //
380
382
.containsExactlyInAnyOrder (MethodSource .from (testClass .getDeclaredMethod ("test1" )),
You can’t perform that action at this time.
0 commit comments