Overview
In Spring Framework's test suite, I introduced a test fixture to replicate an issued reported by a user, where the user had a @Nested test class that extended an abstract inner class.
That is naturally supported and works fine; however, the new discovery issue reporting feature introduced in JUnit 5.13 incorrectly warns that such a declaration is invalid.
For example, when running MockitoBeanNestedAndTypeHierarchiesWithSuperclassPresentTwiceTests in spring-test, I see the following warning.
WARNING: TestEngine with ID 'junit-jupiter' encountered a non-critical issue during test discovery:
(1) [WARNING] Inner class 'org.springframework.test.context.bean.override.mockito.MockitoBeanNestedAndTypeHierarchiesWithEnclosingClassPresentTwiceTests$AbstractBaseClassForNestedTests' looks like it was intended to be a test class but will not be executed. It must be static or annotated with @Nested.
Source: ClassSource [className = 'org.springframework.test.context.bean.override.mockito.MockitoBeanNestedAndTypeHierarchiesWithEnclosingClassPresentTwiceTests$AbstractBaseClassForNestedTests', filePosition = null]
at org.springframework.test.context.bean.override.mockito.MockitoBeanNestedAndTypeHierarchiesWithEnclosingClassPresentTwiceTests$AbstractBaseClassForNestedTests.<no-method>(SourceFile:0)
Note that AbstractBaseClassForNestedTests is inherited from AbstractMockitoBeanNestedAndTypeHierarchiesWithSuperclassPresentTwiceTests, and it is intentionally not "static or annotated with @Nested."
Thus, I think the discovery issue check should be updated so that it does not report that, if the inner class in question is abstract.
Related Issues
Overview
In Spring Framework's test suite, I introduced a test fixture to replicate an issued reported by a user, where the user had a
@Nestedtest class that extended anabstractinner class.That is naturally supported and works fine; however, the new discovery issue reporting feature introduced in JUnit 5.13 incorrectly warns that such a declaration is invalid.
For example, when running
MockitoBeanNestedAndTypeHierarchiesWithSuperclassPresentTwiceTestsinspring-test, I see the following warning.Note that
AbstractBaseClassForNestedTestsis inherited fromAbstractMockitoBeanNestedAndTypeHierarchiesWithSuperclassPresentTwiceTests, and it is intentionally not "static or annotated with@Nested."Thus, I think the discovery issue check should be updated so that it does not report that, if the inner class in question is
abstract.Related Issues
@Testmethod in abstract class #4636