diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java index 5dfe8ccea9b61..454ded5d53195 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java @@ -34,6 +34,7 @@ import org.apache.commons.lang3.RandomStringUtils; import org.eclipse.microprofile.config.Config; +import org.eclipse.microprofile.config.inject.ConfigProperty; import org.jboss.jandex.Index; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.platform.commons.JUnitException; @@ -72,13 +73,18 @@ static void ensureNoInjectAnnotationIsUsed(Class testClass) { Class current = testClass; while (current.getSuperclass() != null) { for (Field field : current.getDeclaredFields()) { - Inject injectAnnotation = field.getAnnotation(Inject.class); - if (injectAnnotation != null) { + if (field.getAnnotation(Inject.class) != null) { throw new JUnitException( "@Inject is not supported in @NativeImageTest and @QuarkusIntegrationTest tests. Offending field is " + field.getDeclaringClass().getTypeName() + "." + field.getName()); } + if (field.getAnnotation(ConfigProperty.class) != null) { + throw new JUnitException( + "@ConfigProperty is not supported in @NativeImageTest and @QuarkusIntegrationTest tests. Offending field is " + + field.getDeclaringClass().getTypeName() + "." + + field.getName()); + } } current = current.getSuperclass(); }