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) {
6363 .and (isInner (issueReporter ));
6464 this .isValidStandaloneTestClass = isNotPrivateUnlessAbstract ("Test" , issueReporter ) //
6565 .and (isNotLocal (issueReporter )) //
66- .and (isNotInner (issueReporter )) // or should be annotated with @Nested!
66+ .and (isNotInnerUnlessAbstract (issueReporter )) //
6767 .and (isNotAnonymous (issueReporter ));
6868 }
6969
@@ -127,8 +127,8 @@ private static Condition<Class<?>> isInner(DiscoveryIssueReporter issueReporter)
127127 });
128128 }
129129
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 ) ,
132132 testClass -> createIssue ("Test" , testClass , "must not be an inner class unless annotated with @Nested" ));
133133 }
134134
Original file line number Diff line number Diff line change @@ -231,12 +231,20 @@ void individualMethodsWithinRecursiveNestedTestClassHierarchiesAreExecuted() {
231231 }
232232
233233 @ Test
234- void doesNotReportDiscoveryIssueForAbstractInnerClass () {
234+ void doesNotReportDiscoveryIssueForClassWithAbstractInnerClass () {
235235 var discoveryIssues = discoverTestsForClass (ConcreteWithExtendedInnerClassTestCase .class ).getDiscoveryIssues ();
236236
237237 assertThat (discoveryIssues ).isEmpty ();
238238 }
239239
240+ @ Test
241+ void doesNotReportDiscoveryIssueForAbstractInnerClass () {
242+ var discoveryIssues = discoverTestsForClass (
243+ AbstractBaseWithInnerClassTestCase .AbstractInnerClass .class ).getDiscoveryIssues ();
244+
245+ assertThat (discoveryIssues ).isEmpty ();
246+ }
247+
240248 private void assertNestedCycle (Class <?> start , Class <?> from , Class <?> to ) {
241249 var results = executeTestsForClass (start );
242250 var expectedMessage = String .format (
You can’t perform that action at this time.
0 commit comments