File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/discovery/predicates
jupiter-tests/src/test/java/org/junit/jupiter/engine Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ public TestClassPredicates(DiscoveryIssueReporter issueReporter) {
63
63
.and (isInner (issueReporter ));
64
64
this .isValidStandaloneTestClass = isNotPrivateUnlessAbstract ("Test" , issueReporter ) //
65
65
.and (isNotLocal (issueReporter )) //
66
- .and (isNotInner (issueReporter )) // or should be annotated with @Nested!
66
+ .and (isNotInnerUnlessAbstract (issueReporter )) //
67
67
.and (isNotAnonymous (issueReporter ));
68
68
}
69
69
@@ -127,8 +127,8 @@ private static Condition<Class<?>> isInner(DiscoveryIssueReporter issueReporter)
127
127
});
128
128
}
129
129
130
- private static Condition <Class <?>> isNotInner (DiscoveryIssueReporter issueReporter ) {
131
- return issueReporter .createReportingCondition (testClass -> !isInnerClass (testClass ),
130
+ private static Condition <Class <?>> isNotInnerUnlessAbstract (DiscoveryIssueReporter issueReporter ) {
131
+ return issueReporter .createReportingCondition (testClass -> !isInnerClass (testClass ) || isAbstract ( testClass ) ,
132
132
testClass -> createIssue ("Test" , testClass , "must not be an inner class unless annotated with @Nested" ));
133
133
}
134
134
Original file line number Diff line number Diff line change @@ -231,12 +231,20 @@ void individualMethodsWithinRecursiveNestedTestClassHierarchiesAreExecuted() {
231
231
}
232
232
233
233
@ Test
234
- void doesNotReportDiscoveryIssueForAbstractInnerClass () {
234
+ void doesNotReportDiscoveryIssueForClassWithAbstractInnerClass () {
235
235
var discoveryIssues = discoverTestsForClass (ConcreteWithExtendedInnerClassTestCase .class ).getDiscoveryIssues ();
236
236
237
237
assertThat (discoveryIssues ).isEmpty ();
238
238
}
239
239
240
+ @ Test
241
+ void doesNotReportDiscoveryIssueForAbstractInnerClass () {
242
+ var discoveryIssues = discoverTestsForClass (
243
+ AbstractBaseWithInnerClassTestCase .AbstractInnerClass .class ).getDiscoveryIssues ();
244
+
245
+ assertThat (discoveryIssues ).isEmpty ();
246
+ }
247
+
240
248
private void assertNestedCycle (Class <?> start , Class <?> from , Class <?> to ) {
241
249
var results = executeTestsForClass (start );
242
250
var expectedMessage = String .format (
You can’t perform that action at this time.
0 commit comments