@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:
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
}
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 theexample.FruitUtils#tropicalFruits
field.Related Issues
51
54
636