diff --git a/test-framework/junit5-component/src/main/java/io/quarkus/test/component/QuarkusComponentTest.java b/test-framework/junit5-component/src/main/java/io/quarkus/test/component/QuarkusComponentTest.java index 5b26337f7966d..1aba39aa6beb5 100644 --- a/test-framework/junit5-component/src/main/java/io/quarkus/test/component/QuarkusComponentTest.java +++ b/test-framework/junit5-component/src/main/java/io/quarkus/test/component/QuarkusComponentTest.java @@ -8,10 +8,14 @@ import org.junit.jupiter.api.extension.ExtendWith; +import io.quarkus.test.InjectMock; import io.smallrye.common.annotation.Experimental; /** * Registers the {@link QuarkusComponentTestExtension} that makes it easy to test Quarkus components. + * + * @see InjectMock + * @see TestConfigProperty */ @Experimental("This feature is experimental and the API may change in the future") @ExtendWith(QuarkusComponentTestExtension.class) diff --git a/test-framework/junit5-component/src/main/java/io/quarkus/test/component/QuarkusComponentTestExtension.java b/test-framework/junit5-component/src/main/java/io/quarkus/test/component/QuarkusComponentTestExtension.java index 51e3bec34d887..865fb1b31a398 100644 --- a/test-framework/junit5-component/src/main/java/io/quarkus/test/component/QuarkusComponentTestExtension.java +++ b/test-framework/junit5-component/src/main/java/io/quarkus/test/component/QuarkusComponentTestExtension.java @@ -124,6 +124,9 @@ * configuration properties via the {@link #configProperty(String, String)} method. If you only need to use the default values * for missing config properties, then the {@link #useDefaultConfigProperties()} * might come in useful. + * + * @see InjectMock + * @see TestConfigProperty */ @Experimental("This feature is experimental and the API may change in the future") public class QuarkusComponentTestExtension @@ -195,7 +198,7 @@ public QuarkusComponentTestExtension configProperty(String key, String value) { } /** - * Use the default values for missing config properties. By default, if missing config property results in a test failure. + * Use the default values for missing config properties. By default, a missing config property results in a test failure. *
* For primitives the default values as defined in the JLS are used. For any other type {@code null} is injected.
*
@@ -246,10 +249,14 @@ public void beforeAll(ExtensionContext context) throws Exception {
}
}
// All fields annotated with @Inject represent component classes
- for (Field field : testClass.getDeclaredFields()) {
- if (field.isAnnotationPresent(Inject.class) && !resolvesToBuiltinBean(field.getType())) {
- componentClasses.add(field.getType());
+ Class> current = testClass;
+ while (current != null) {
+ for (Field field : current.getDeclaredFields()) {
+ if (field.isAnnotationPresent(Inject.class) && !resolvesToBuiltinBean(field.getType())) {
+ componentClasses.add(field.getType());
+ }
}
+ current = current.getSuperclass();
}
TestConfigProperty[] testConfigProperties = testClass.getAnnotationsByType(TestConfigProperty.class);
@@ -761,13 +768,17 @@ private List