38
38
import org .junit .jupiter .api .extension .ParameterResolutionException ;
39
39
import org .junit .jupiter .api .extension .ParameterResolver ;
40
40
import org .junit .platform .commons .support .AnnotationSupport ;
41
- import org .junit .platform .commons .support .SearchOption ;
42
41
43
42
import org .springframework .util .StreamUtils ;
44
43
@@ -66,7 +65,7 @@ public void beforeEach(ExtensionContext context) throws Exception {
66
65
resourcesOf (testMethod )
67
66
.forEach ((resource ) -> resources .addResource (resource .name (), resource .content (), resource .additional ()));
68
67
resourceDirectoriesOf (testMethod ).forEach ((directory ) -> resources .addDirectory (directory .value ()));
69
- packageResourcesOf (testMethod ).forEach ((withPackageResources ) -> resources
68
+ packageResourcesOf (testMethod , context ).forEach ((withPackageResources ) -> resources
70
69
.addPackage (testMethod .getDeclaringClass ().getPackage (), withPackageResources .value ()));
71
70
ResourcesClassLoader classLoader = new ResourcesClassLoader (context .getRequiredTestClass ().getClassLoader (),
72
71
resources );
@@ -93,12 +92,11 @@ private <A extends Annotation> List<A> withAnnotationsOf(Method method, Class<A>
93
92
return annotations ;
94
93
}
95
94
96
- private List <WithPackageResources > packageResourcesOf (Method method ) {
95
+ private List <WithPackageResources > packageResourcesOf (Method method , ExtensionContext context ) {
97
96
List <WithPackageResources > annotations = new ArrayList <>();
98
97
AnnotationSupport .findAnnotation (method , WithPackageResources .class ).ifPresent (annotations ::add );
99
98
AnnotationSupport
100
- .findAnnotation (method .getDeclaringClass (), WithPackageResources .class ,
101
- SearchOption .INCLUDE_ENCLOSING_CLASSES )
99
+ .findAnnotation (method .getDeclaringClass (), WithPackageResources .class , context .getEnclosingTestClasses ())
102
100
.ifPresent (annotations ::add );
103
101
return annotations ;
104
102
}
0 commit comments