Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ repository on GitHub.
that both `null` and _blank_ values are supported for reason strings and that such
values will result in an _empty_ `Optional` returned from
`ConditionEvaluationResult.getReason()`.
* Improve message of discovery issues reported for ineffective `@Order` annotations.


[[release-notes-5.13.3-junit-vintage]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.junit.platform.engine.DiscoveryIssue;
import org.junit.platform.engine.DiscoveryIssue.Severity;
import org.junit.platform.engine.TestDescriptor;
import org.junit.platform.engine.support.descriptor.ClassSource;
import org.junit.platform.engine.support.discovery.DiscoveryIssueReporter;
import org.junit.platform.engine.support.discovery.DiscoveryIssueReporter.Condition;

Expand All @@ -49,10 +48,12 @@ class ClassOrderingVisitor extends AbstractOrderingVisitor {
this.globalOrderer = createGlobalOrderer(configuration);
this.noOrderAnnotation = issueReporter.createReportingCondition(
testDescriptor -> !isAnnotated(testDescriptor.getTestClass(), Order.class), testDescriptor -> {
String message = "Ineffective @Order annotation on class '%s'. It will not be applied because ClassOrderer.OrderAnnotation is not in use.".formatted(
testDescriptor.getTestClass().getName());
String message = "Ineffective @Order annotation on class '%s'. ".formatted(
testDescriptor.getTestClass().getName())
+ "The annotation may be directly present or meta-present on the class. "
+ "It will not be applied because ClassOrderer.OrderAnnotation is not in use.";
return DiscoveryIssue.builder(Severity.INFO, message) //
.source(ClassSource.from(testDescriptor.getTestClass())) //
.source(testDescriptor.getSource()) //
.build();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.junit.platform.engine.DiscoveryIssue;
import org.junit.platform.engine.DiscoveryIssue.Severity;
import org.junit.platform.engine.TestDescriptor;
import org.junit.platform.engine.support.descriptor.MethodSource;
import org.junit.platform.engine.support.discovery.DiscoveryIssueReporter;
import org.junit.platform.engine.support.discovery.DiscoveryIssueReporter.Condition;

Expand All @@ -50,10 +49,12 @@ class MethodOrderingVisitor extends AbstractOrderingVisitor {
this.configuration = configuration;
this.noOrderAnnotation = issueReporter.createReportingCondition(
testDescriptor -> !isAnnotated(testDescriptor.getTestMethod(), Order.class), testDescriptor -> {
String message = "Ineffective @Order annotation on method '%s'. It will not be applied because MethodOrderer.OrderAnnotation is not in use.".formatted(
testDescriptor.getTestMethod().toGenericString());
String message = "Ineffective @Order annotation on method '%s'. ".formatted(
testDescriptor.getTestMethod().toGenericString())
+ "The annotation may be directly present or meta-present on the method. "
+ "It will not be applied because MethodOrderer.OrderAnnotation is not in use.";
return DiscoveryIssue.builder(Severity.INFO, message) //
.source(MethodSource.from(testDescriptor.getTestMethod())) //
.source(testDescriptor.getSource()) //
.build();
});
this.methodsBeforeNestedClassesOrderer = createMethodsBeforeNestedClassesOrderer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ private static void assertIneffectiveOrderAnnotationIssues(List<DiscoveryIssue>
assertThat(discoveryIssues).extracting(DiscoveryIssue::severity).containsOnly(Severity.INFO);
assertThat(discoveryIssues).extracting(DiscoveryIssue::message) //
.allMatch(it -> it.startsWith("Ineffective @Order annotation on class")
&& it.contains("The annotation may be directly present or meta-present on the class.")
&& it.endsWith("It will not be applied because ClassOrderer.OrderAnnotation is not in use."));
assertThat(discoveryIssues).extracting(DiscoveryIssue::source).extracting(Optional::orElseThrow) //
.containsExactlyInAnyOrder(ClassSource.from(A_TestCase.class), ClassSource.from(C_TestCase.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ private static void assertIneffectiveOrderAnnotationIssues(List<DiscoveryIssue>
assertThat(discoveryIssues).extracting(DiscoveryIssue::severity).containsOnly(Severity.INFO);
assertThat(discoveryIssues).extracting(DiscoveryIssue::message) //
.allMatch(it -> it.startsWith("Ineffective @Order annotation on method")
&& it.contains("The annotation may be directly present or meta-present on the method.")
&& it.endsWith("It will not be applied because MethodOrderer.OrderAnnotation is not in use."));
var testClass = WithoutTestMethodOrderTestCase.class;
assertThat(discoveryIssues).extracting(DiscoveryIssue::source).extracting(Optional::orElseThrow) //
Expand Down