-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interfaces implemented by test classes are not registered for reflection #636
Comments
Thanks for reporting, this is on our short-term plan and we will look into it. Our future implementation of the JUnit feature will have to register this metadata based on the test annotations. |
Hi @vjovanov,
I apologize: my use of NBT already has specific support for registering reflection metadata for fully-qualified method names configured via Lines 144 to 166 in 979e9ec
If the method name is not fully-qualified, that simply logs a debug message: debug("Skipping method reference as it originates in the same class as the test: %s", methodName); That "same class" part actually applies to the test class hierarchy; however, it should apply to the entire type hierarchy. Hence, the following passes both on the JVM and within a native image, but my original example with class BaseTests {
static List<String> names() {
return List.of("Sarah", "Susan");
}
} class DemoTests extends BaseTests {
@ParameterizedTest
@MethodSource("names")
void test(String name) {
assertEquals(5, name.length());
assertTrue(name.startsWith("S"));
}
} The larger issue is that "test interfaces" are ignored in See also: Test Interfaces and Default Methods in the JUnit 5 User Guide.
As I mentioned above, that is already covered by the The fix for this issue should likely be as simple as modifying the If you need any further clarification, just let me know. Thanks, Sam |
Overview
Given the following interface:
... and the following test class:
...
DemoTests
passes on the JVM but fails within a native image as follows.However, if
TestInterface
were a class thatDemoTests
extended the test would then pass.The reason is that the
JUnitPlatformFeature
currently invokesregisterAllClassMembersForReflection()
for all classes with the test class hierarchy, but that recursive algorithm ignores implemented interfaces.native-build-tools/common/junit-platform-native/src/main/java/org/graalvm/junit/platform/JUnitPlatformFeature.java
Lines 150 to 158 in 979e9ec
The
registerTestClassForReflection()
method inJUnitPlatformFeature
should therefore be revised to process implemented interfaces (and super-interfaces) at each level of the class hierarchy.Related Issues
@ParameterizedTest
with@MethodSource
are not supported. #51@ExtendWith
,@ArgumentsSource
, etc. for reflection #54@FieldSource
for@ParameterizedTest
methods #638The text was updated successfully, but these errors were encountered: