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
Support CharSequence argument for Fallback String-to-Object Conversion
Prior to this commit, the Fallback String-to-Object Conversion support
for parameterized tests supported factory constructors and methods that
accepted a single String argument.
This commit relaxes that restriction to support factory constructors
and methods that accept either a single String argument or a single
CharSequence argument, since the original source String can always be
supplied to an Executable that accepts a CharSequence. For backward
compatibility, the search algorithm gives precedence to factories that
accept String arguments, only falling back to factories that accept
CharSequence arguments if necessary.
Note that this change is available to third parties via
ConversionSupport in junit-platform-commons, which junit-jupiter-params
utilizes.
Closes#4815
Copy file name to clipboardExpand all lines: junit-platform-commons/src/main/java/org/junit/platform/commons/support/conversion/FallbackStringToObjectConverter.java
+53-39Lines changed: 53 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -38,16 +38,21 @@
38
38
* <h2>Search Algorithm</h2>
39
39
*
40
40
* <ol>
41
-
* <li>Search for a single, non-private static factory method in the target
42
-
* type that converts from a String to the target type. Use the factory method
41
+
* <li>Search for a single, non-private static factory method in the target type
42
+
* that converts from a {@link String} to the target type. Use the factory method
43
43
* if present.</li>
44
-
* <li>Search for a single, non-private constructor in the target type that
45
-
* accepts a String. Use the constructor if present.</li>
44
+
* <li>Search for a single, non-private constructor in the target type that accepts
45
+
* a {@link String}. Use the constructor if present.</li>
46
+
* <li>Search for a single, non-private static factory method in the target type
47
+
* that converts from a {@link CharSequence} to the target type. Use the factory
48
+
* method if present.</li>
49
+
* <li>Search for a single, non-private constructor in the target type that accepts
50
+
* a {@link CharSequence}. Use the constructor if present.</li>
46
51
* </ol>
47
52
*
48
-
* <p>If multiple suitable factory methods are discovered they will be ignored.
49
-
* If neither a single factory method nor a single constructor is found, this
50
-
* converter acts as a no-op.
53
+
* <p>If multiple suitable factory methods or constructors are discovered they
54
+
* will be ignored. If neither a single factory method nor a single constructor
55
+
* is found, this converter acts as a no-op.
51
56
*
52
57
* @since 1.11
53
58
* @see ConversionSupport
@@ -86,28 +91,47 @@ public boolean canConvertTo(Class<?> targetType) {
0 commit comments