graalvm / native-build-tools

Native-image plugins for various build tools
https://graalvm.github.io/native-build-tools/
Other
371 stars 60 forks source link

Add support for `@FieldSource` for `@ParameterizedTest` methods #638

Open sbrannen opened 3 weeks ago

sbrannen commented 3 weeks ago

Overview

@FieldSource was introduced in JUnit Jupiter 5.11 for use with @ParameterizedTest methods.

Similar to @MethodSource which allows developers to supply a fully-qualified method name, @FieldSource allows developers to supply a fully-qualified field name.

Native Build Tools already registers reflection metadata for fully-qualified method names for @MethodSource here:

https://github.com/graalvm/native-build-tools/blob/979e9ecfcc8d2c4e35808022b3c6724212bc4417/common/junit-platform-native/src/main/java/org/graalvm/junit/platform/config/jupiter/JupiterConfigProvider.java#L144-L166

Similar support should be added for @FieldSource. For example, given the following parameterized test, reflection metadata should be registered for the example.FruitUtils#tropicalFruits field.

@ParameterizedTest
@FieldSource("example.FruitUtils#tropicalFruits")
void testWithExternalFieldSource(String tropicalFruit) {
    // test with tropicalFruit
}

Related Issues