You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@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:
* If the method used as an argument source resides in a different class than the test class, it must be specified
* by the fully qualified class name, followed by a # and the method name
*/
debug("Found method reference: %s", methodName);
if (parts.length == 2) {
StringclassName = parts[0];
debug("Processing method reference from another class: %s", className);
try {
classList.add(Class.forName(className));
} catch (ClassNotFoundExceptione) {
debug("Failed to register method reference for reflection: %s Reason: %s", className, e);
}
} else {
debug("Skipping method reference as it originates in the same class as the test: %s", methodName);
}
}
returnclassList.toArray(newClass<?>[0]);
}
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")
voidtestWithExternalFieldSource(StringtropicalFruit) {
// 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:native-build-tools/common/junit-platform-native/src/main/java/org/graalvm/junit/platform/config/jupiter/JupiterConfigProvider.java
Lines 144 to 166 in 979e9ec
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
@ParameterizedTest
with@MethodSource
are not supported. #51@ExtendWith
,@ArgumentsSource
, etc. for reflection #54The text was updated successfully, but these errors were encountered: