diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java index 3d33b764ce..e1e013d8c6 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java @@ -222,6 +222,7 @@ class ImportsContextCustomizer implements ContextCustomizer { filters.add(new JavaLangAnnotationFilter()); filters.add(new KotlinAnnotationFilter()); filters.add(new SpockAnnotationFilter()); + filters.add(new JunitAnnotationFilter()); ANNOTATION_FILTERS = Collections.unmodifiableSet(filters); } @@ -384,4 +385,15 @@ class ImportsContextCustomizer implements ContextCustomizer { } + /** + * {@link AnnotationFilter} for Spock annotations. + */ + private static final class JunitAnnotationFilter implements AnnotationFilter { + + @Override + public boolean isIgnored(Annotation annotation) { + return annotation.annotationType().getName().startsWith("org.junit."); + } + + } }