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
thrownewArgumentConversionException("Cannot convert null to " + targetClass.getName());
}
In my tests, it would come in handy if I could just set a null string in my CsvSource and have the JavaTimeArgumentConverter null the Java Time parameter.
I would suggest making this behaviour configurable via the JavaTimeConversionPattern annotation, such as:
Thanks for raising this! I think your proposed solution makes sense. We should point to the new nullable attribute in the message of the ArgumentConversionException when it's set to false.
good to hear! I opened a PR and included your suggestion to mention the nullable option in the ArgumentConversionException. Let me know if I should change anything.
sbrannen
changed the title
Nullable Java Time parameters in parameterized tests
Suppor nullable Java Date/Time arguments in @ParameterizedTest methods
Sep 20, 2024
sbrannen
changed the title
Suppor nullable Java Date/Time arguments in @ParameterizedTest methods
Support nullable Java Date/Time arguments in @ParameterizedTest methods
Sep 20, 2024
When supplying a Java Time parameter in parameterized tests, it is not possible to null the parameter by supplying a null-String:
junit5/junit-jupiter-params/src/main/java/org/junit/jupiter/params/converter/JavaTimeArgumentConverter.java
Lines 52 to 56 in 6be5547
In my tests, it would come in handy if I could just set a null string in my
CsvSource
and have theJavaTimeArgumentConverter
null the Java Time parameter.I would suggest making this behaviour configurable via the
JavaTimeConversionPattern
annotation, such as:(with the old behaviour being the default).
Let me know what you think. If you deem this feature useful, I'd be happy to provide a PR for this.
Deliverables
JavaTimeArgumentConverter
convert null-valuesThe text was updated successfully, but these errors were encountered: