|
54 | 54 | import org.junit.jupiter.params.converter.ConvertWith; |
55 | 55 | import org.junit.jupiter.params.provider.ArgumentsSource; |
56 | 56 | import org.junit.jupiter.params.provider.EnumSource; |
57 | | -import org.junit.jupiter.params.provider.MethodSource; |
58 | 57 | import org.junit.jupiter.params.provider.FieldSource; |
| 58 | +import org.junit.jupiter.params.provider.MethodSource; |
59 | 59 |
|
60 | 60 | import java.lang.reflect.Method; |
61 | 61 | import java.util.ArrayList; |
@@ -86,9 +86,15 @@ public void onTestClassRegistered(Class<?> testClass, NativeImageConfiguration r |
86 | 86 | AnnotationUtils.forEachAnnotatedMethodParameter(testClass, AggregateWith.class, annotation -> registry.registerAllClassMembersForReflection(annotation.value())); |
87 | 87 | AnnotationUtils.forEachAnnotatedMethod(testClass, EnumSource.class, (m, annotation) -> handleEnumSource(m, annotation, registry)); |
88 | 88 | AnnotationUtils.registerClassesFromAnnotationForReflection(testClass, registry, MethodSource.class, JupiterConfigProvider::handleMethodSource); |
89 | | - AnnotationUtils.registerClassesFromAnnotationForReflection(testClass, registry, FieldSource.class, JupiterConfigProvider::handleFieldSource); |
90 | 89 | AnnotationUtils.registerClassesFromAnnotationForReflection(testClass, registry, EnabledIf.class, JupiterConfigProvider::handleEnabledIf); |
91 | 90 | AnnotationUtils.registerClassesFromAnnotationForReflection(testClass, registry, DisabledIf.class, JupiterConfigProvider::handleDisabledIf); |
| 91 | + |
| 92 | + try { |
| 93 | + AnnotationUtils.registerClassesFromAnnotationForReflection(testClass, registry, FieldSource.class, JupiterConfigProvider::handleFieldSource); |
| 94 | + } catch (NoClassDefFoundError e) { |
| 95 | + // if users use JUnit version older than 5.11, FieldSource class won't be available |
| 96 | + } |
| 97 | + |
92 | 98 | } |
93 | 99 |
|
94 | 100 | private static Class<?>[] handleMethodSource(MethodSource annotation) { |
|
0 commit comments