3838import org .junit .jupiter .api .extension .ParameterResolutionException ;
3939import org .junit .jupiter .api .extension .ParameterResolver ;
4040import org .junit .platform .commons .support .AnnotationSupport ;
41- import org .junit .platform .commons .support .SearchOption ;
4241
4342import org .springframework .util .StreamUtils ;
4443
@@ -66,7 +65,7 @@ public void beforeEach(ExtensionContext context) throws Exception {
6665 resourcesOf (testMethod )
6766 .forEach ((resource ) -> resources .addResource (resource .name (), resource .content (), resource .additional ()));
6867 resourceDirectoriesOf (testMethod ).forEach ((directory ) -> resources .addDirectory (directory .value ()));
69- packageResourcesOf (testMethod ).forEach ((withPackageResources ) -> resources
68+ packageResourcesOf (testMethod , context ).forEach ((withPackageResources ) -> resources
7069 .addPackage (testMethod .getDeclaringClass ().getPackage (), withPackageResources .value ()));
7170 ResourcesClassLoader classLoader = new ResourcesClassLoader (context .getRequiredTestClass ().getClassLoader (),
7271 resources );
@@ -93,12 +92,11 @@ private <A extends Annotation> List<A> withAnnotationsOf(Method method, Class<A>
9392 return annotations ;
9493 }
9594
96- private List <WithPackageResources > packageResourcesOf (Method method ) {
95+ private List <WithPackageResources > packageResourcesOf (Method method , ExtensionContext context ) {
9796 List <WithPackageResources > annotations = new ArrayList <>();
9897 AnnotationSupport .findAnnotation (method , WithPackageResources .class ).ifPresent (annotations ::add );
9998 AnnotationSupport
100- .findAnnotation (method .getDeclaringClass (), WithPackageResources .class ,
101- SearchOption .INCLUDE_ENCLOSING_CLASSES )
99+ .findAnnotation (method .getDeclaringClass (), WithPackageResources .class , context .getEnclosingTestClasses ())
102100 .ifPresent (annotations ::add );
103101 return annotations ;
104102 }
0 commit comments