Skip to content

Commit de69942

Browse files
committed
Sync Javadoc and User Guide for @CsvSource and @CsvFileSource
1 parent 105fb62 commit de69942

File tree

3 files changed

+53
-10
lines changed

3 files changed

+53
-10
lines changed

documentation/src/docs/asciidoc/user-guide/writing-tests.adoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -1374,8 +1374,8 @@ reference is a primitive type.
13741374
NOTE: An _unquoted_ empty value will always be converted to a `null` reference regardless
13751375
of any custom values configured via the `nullValues` attribute.
13761376

1377-
Unless it starts with a quote character, leading and trailing whitespace in a CSV column
1378-
is trimmed by default. This behavior can be changed by setting the
1377+
Except within a quoted string, leading and trailing whitespace in a CSV column is trimmed
1378+
by default. This behavior can be changed by setting the
13791379
`ignoreLeadingAndTrailingWhitespace` attribute to `true`.
13801380

13811381
[cols="50,50"]
@@ -1428,8 +1428,8 @@ reference is a primitive type.
14281428
NOTE: An _unquoted_ empty value will always be converted to a `null` reference regardless
14291429
of any custom values configured via the `nullValues` attribute.
14301430

1431-
Unless it starts with a quote character, leading and trailing whitespace in a CSV column
1432-
is trimmed by default. This behavior can be changed by setting the
1431+
Except within a quoted string, leading and trailing whitespace in a CSV column is trimmed
1432+
by default. This behavior can be changed by setting the
14331433
`ignoreLeadingAndTrailingWhitespace` attribute to `true`.
14341434

14351435
[[writing-tests-parameterized-tests-sources-ArgumentsSource]]

junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvFileSource.java

+27-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,33 @@
2626
* comma-separated value (CSV) files from one or more classpath {@link #resources
2727
* resources} or {@link #files}.
2828
*
29-
* <p>The lines of these CSV files will be provided as arguments to the
30-
* annotated {@code @ParameterizedTest} method. Any line beginning with a
31-
* {@code #} symbol will be interpreted as a comment and will be ignored.
29+
* <p>The lines of these CSV files will be provided as arguments to the annotated
30+
* {@code @ParameterizedTest} method.
31+
*
32+
* <p>Any line beginning with a {@code #} symbol will be interpreted as a comment
33+
* and will be ignored.
34+
*
35+
* <p>The column delimiter (defaults to comma) can be customized with either
36+
* {@link #delimiter} or {@link #delimiterString}.
37+
*
38+
* <p>In contrast to the syntax used in {@code @CsvSource}, {@code @CsvFileSource}
39+
* uses a double quote ({@code "}) as its quote character (see the User Guide for
40+
* examples). An empty, quoted value ({@code ""}) results in an empty {@link String}
41+
* unless the {@link #emptyValue} attribute is set; whereas, an entirely <em>empty</em>
42+
* value is interpreted as a {@code null} reference. By specifying one or more
43+
* {@link #nullValues} a custom value can be interpreted as a {@code null} reference
44+
* (see the User Guide for an example). An
45+
* {@link org.junit.jupiter.params.converter.ArgumentConversionException
46+
* ArgumentConversionException} is thrown if the target type of a {@code null}
47+
* reference is a primitive type.
48+
*
49+
* <p>NOTE: An <em>unquoted</em> empty value will always be converted to a
50+
* {@code null} reference regardless of any custom values configured via the
51+
* {@link #nullValues} attribute.
52+
*
53+
* <p>Except within a quoted string, leading and trailing whitespace in a CSV
54+
* column is trimmed by default. This behavior can be changed by setting the
55+
* {@link #ignoreLeadingAndTrailingWhitespace} attribute to {@code true}.
3256
*
3357
* @since 5.0
3458
* @see CsvSource

junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvSource.java

+22-3
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,30 @@
2626
* values (CSV) from one or more CSV lines supplied via the {@link #value}
2727
* attribute or {@link #textBlock} attribute.
2828
*
29+
* <p>The supplied values will be provided as arguments to the annotated
30+
* {@code @ParameterizedTest} method.
31+
*
2932
* <p>The column delimiter (defaults to comma) can be customized with either
30-
* {@link #delimiter()} or {@link #delimiterString()}.
33+
* {@link #delimiter} or {@link #delimiterString}.
34+
*
35+
* <p>{@code @CsvSource} uses a single quote ({@code '}) as its quote character.
36+
* See the {@code 'lemon, lime'} examples in the documentation for the {@link #value}
37+
* and {@link #textBlock} attributes. An empty, quoted value ({@code ''}) results
38+
* in an empty {@link String} unless the {@link #emptyValue} attribute is set;
39+
* whereas, an entirely <em>empty</em> value is interpreted as a {@code null} reference.
40+
* By specifying one or more {@link #nullValues} a custom value can be interpreted
41+
* as a {@code null} reference (see the User Guide for an example). An
42+
* {@link org.junit.jupiter.params.converter.ArgumentConversionException
43+
* ArgumentConversionException} is thrown if the target type of a {@code null}
44+
* reference is a primitive type.
45+
*
46+
* <p>NOTE: An <em>unquoted</em> empty value will always be converted to a
47+
* {@code null} reference regardless of any custom values configured via the
48+
* {@link #nullValues} attribute.
3149
*
32-
* <p>The supplied values will be provided as arguments to the
33-
* annotated {@code @ParameterizedTest} method.
50+
* <p>Except within a quoted string, leading and trailing whitespace in a CSV
51+
* column is trimmed by default. This behavior can be changed by setting the
52+
* {@link #ignoreLeadingAndTrailingWhitespace} attribute to {@code true}.
3453
*
3554
* @since 5.0
3655
* @see CsvFileSource

0 commit comments

Comments
 (0)