Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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,13 @@ 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'. \
It will not be applied because ClassOrderer.OrderAnnotation is not in use. \
Note that the annotation may be either directly present or meta-present on the class."""//
.formatted(testDescriptor.getTestClass().getName());
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,13 @@ 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'. \
It will not be applied because MethodOrderer.OrderAnnotation is not in use. \
Note that the annotation may be either directly present or meta-present on the method."""//
.formatted(testDescriptor.getTestMethod().toGenericString());
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,7 +205,9 @@ 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.endsWith("It will not be applied because ClassOrderer.OrderAnnotation is not in use."));
&& it.contains("It will not be applied because ClassOrderer.OrderAnnotation is not in use.")
&& it.endsWith(
"Note that the annotation may be either directly present or meta-present on the class."));
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,7 +374,9 @@ 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.endsWith("It will not be applied because MethodOrderer.OrderAnnotation is not in use."));
&& it.contains("It will not be applied because MethodOrderer.OrderAnnotation is not in use.")
&& it.endsWith(
"Note that the annotation may be either directly present or meta-present on the method."));
var testClass = WithoutTestMethodOrderTestCase.class;
assertThat(discoveryIssues).extracting(DiscoveryIssue::source).extracting(Optional::orElseThrow) //
.containsExactlyInAnyOrder(MethodSource.from(testClass.getDeclaredMethod("test1")),
Expand Down