diff --git a/gradle.properties b/gradle.properties index edd3e2a5ed..6c225a1cd7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ graalVersion=22.3 hamcrestVersion=3.0 jacksonVersion=2.18.3 javaFormatVersion=0.0.43 -junitJupiterVersion=5.11.4 +junitJupiterVersion=5.12.1 kotlinVersion=1.9.25 mavenVersion=3.9.4 mockitoVersion=5.16.0 diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/resources/ResourcesExtension.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/resources/ResourcesExtension.java index 4d0d9ab2c9..fa61100ccc 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/resources/ResourcesExtension.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/resources/ResourcesExtension.java @@ -38,7 +38,6 @@ import org.junit.jupiter.api.extension.ParameterContext; import org.junit.jupiter.api.extension.ParameterResolutionException; import org.junit.jupiter.api.extension.ParameterResolver; import org.junit.platform.commons.support.AnnotationSupport; -import org.junit.platform.commons.support.SearchOption; import org.springframework.util.StreamUtils; @@ -66,7 +65,7 @@ class ResourcesExtension implements BeforeEachCallback, AfterEachCallback, Param resourcesOf(testMethod) .forEach((resource) -> resources.addResource(resource.name(), resource.content(), resource.additional())); resourceDirectoriesOf(testMethod).forEach((directory) -> resources.addDirectory(directory.value())); - packageResourcesOf(testMethod).forEach((withPackageResources) -> resources + packageResourcesOf(testMethod, context).forEach((withPackageResources) -> resources .addPackage(testMethod.getDeclaringClass().getPackage(), withPackageResources.value())); ResourcesClassLoader classLoader = new ResourcesClassLoader(context.getRequiredTestClass().getClassLoader(), resources); @@ -93,12 +92,11 @@ class ResourcesExtension implements BeforeEachCallback, AfterEachCallback, Param return annotations; } - private List packageResourcesOf(Method method) { + private List packageResourcesOf(Method method, ExtensionContext context) { List annotations = new ArrayList<>(); AnnotationSupport.findAnnotation(method, WithPackageResources.class).ifPresent(annotations::add); AnnotationSupport - .findAnnotation(method.getDeclaringClass(), WithPackageResources.class, - SearchOption.INCLUDE_ENCLOSING_CLASSES) + .findAnnotation(method.getDeclaringClass(), WithPackageResources.class, context.getEnclosingTestClasses()) .ifPresent(annotations::add); return annotations; } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/build.gradle index e9b9a7d71c..46f3be9a37 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/build.gradle @@ -36,6 +36,8 @@ dependencies { testImplementation("org.assertj:assertj-core") testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.springframework:spring-core") + + testRuntimeOnly("org.junit.platform:junit-platform-launcher") } task syncTestRepository(type: Sync) {