-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support CSV headers in display names in parameterized tests #2759
Comments
sbrannen
changed the title
Use CSV header names in display names in parameterized tests
Support CSV header names in display names in parameterized tests
Oct 29, 2021
sbrannen
changed the title
Support CSV header names in display names in parameterized tests
Support CSV headers in display names in parameterized tests
Oct 29, 2021
sbrannen
added a commit
that referenced
this issue
Oct 29, 2021
sbrannen
added a commit
that referenced
this issue
Oct 29, 2021
Given the following parameterized test that sets useHeadersInDisplayName to true and uses {arguments} instead of {argumentsWithNames} for its display name pattern... @ParameterizedTest(name = "[{index}] {arguments}") @CsvSource(useHeadersInDisplayName = true, textBlock = """ FRUIT, RANK apple, 1 banana, 2 cherry, 3.1415926535 """) void test(String fruit, double rank) {} The generated display names are: [1] FRUIT = apple, RANK = 1 [2] FRUIT = banana, RANK = 2 [3] FRUIT = cherry, RANK = 3.1415926535 See #2759
sbrannen
added a commit
that referenced
this issue
Oct 29, 2021
Given the following parameterized test that sets useHeadersInDisplayName to true and uses {arguments} instead of {argumentsWithNames} for its display name pattern... @ParameterizedTest(name = "[{index}] {arguments}") @CsvSource(useHeadersInDisplayName = true, textBlock = """ FRUIT, RANK apple, 1 banana, 2 cherry, 3 """) void test(String fruit, int rank) {} The generated display names are: [1] FRUIT = apple, RANK = 1 [2] FRUIT = banana, RANK = 2 [3] FRUIT = cherry, RANK = 3 See #2759
sbrannen
added a commit
that referenced
this issue
Oct 29, 2021
Given the following parameterized test that sets useHeadersInDisplayName to true and uses {arguments} instead of {argumentsWithNames} for its display name pattern... @ParameterizedTest(name = "[{index}] {arguments}") @CsvSource(useHeadersInDisplayName = true, textBlock = """ FRUIT, RANK apple, 1 banana, 2 cherry, 3 """) void test(String fruit, int rank) {} The generated display names are: [1] FRUIT = apple, RANK = 1 [2] FRUIT = banana, RANK = 2 [3] FRUIT = cherry, RANK = 3 See #2759
sbrannen
added a commit
that referenced
this issue
Oct 30, 2021
Given the following parameterized test that sets useHeadersInDisplayName to true and uses {arguments} instead of {argumentsWithNames} for its display name pattern... @ParameterizedTest(name = "[{index}] {arguments}") @CsvSource(useHeadersInDisplayName = true, textBlock = """ FRUIT, RANK apple, 1 banana, 2 cherry, 3 """) void test(String fruit, int rank) {} The generated display names are: [1] FRUIT = apple, RANK = 1 [2] FRUIT = banana, RANK = 2 [3] FRUIT = cherry, RANK = 3 See #2759
10 tasks
Superseded by #2767. |
sbrannen
added a commit
to sbrannen/junit5
that referenced
this issue
Nov 19, 2021
Given the following parameterized test that sets useHeadersInDisplayName to true and uses {arguments} instead of {argumentsWithNames} for its display name pattern... @ParameterizedTest(name = "[{index}] {arguments}") @CsvSource(useHeadersInDisplayName = true, textBlock = """ FRUIT, RANK apple, 1 banana, 2 cherry, 3 """) void test(String fruit, int rank) {} The generated display names are: [1] FRUIT = apple, RANK = 1 [2] FRUIT = banana, RANK = 2 [3] FRUIT = cherry, RANK = 3 See junit-team#2759
sbrannen
added a commit
that referenced
this issue
Nov 19, 2021
Given the following parameterized test that sets useHeadersInDisplayName to true and uses {arguments} instead of {argumentsWithNames} for its display name pattern... @ParameterizedTest(name = "[{index}] {arguments}") @CsvSource(useHeadersInDisplayName = true, textBlock = """ FRUIT, RANK apple, 1 banana, 2 cherry, 3 """) void test(String fruit, int rank) {} The generated display names are: [1] FRUIT = apple, RANK = 1 [2] FRUIT = banana, RANK = 2 [3] FRUIT = cherry, RANK = 3 See #2759
sbrannen
added a commit
that referenced
this issue
Nov 19, 2021
Given the following parameterized test that sets useHeadersInDisplayName to true and uses {arguments} instead of {argumentsWithNames} for its display name pattern... @ParameterizedTest(name = "[{index}] {arguments}") @CsvSource(useHeadersInDisplayName = true, textBlock = """ FRUIT, RANK apple, 1 banana, 2 cherry, 3 """) void test(String fruit, int rank) {} The generated display names are: [1] FRUIT = apple, RANK = 1 [2] FRUIT = banana, RANK = 2 [3] FRUIT = cherry, RANK = 3 See #2759
runningcode
pushed a commit
to runningcode/junit5
that referenced
this issue
Feb 15, 2023
Given the following parameterized test that sets useHeadersInDisplayName to true and uses {arguments} instead of {argumentsWithNames} for its display name pattern... @ParameterizedTest(name = "[{index}] {arguments}") @CsvSource(useHeadersInDisplayName = true, textBlock = """ FRUIT, RANK apple, 1 banana, 2 cherry, 3 """) void test(String fruit, int rank) {} The generated display names are: [1] FRUIT = apple, RANK = 1 [2] FRUIT = banana, RANK = 2 [3] FRUIT = cherry, RANK = 3 See junit-team#2759
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Overview
When using
@CsvSource
, CSV headers are not supported. With@CsvFileSource
, the firstn
lines of each file can be skipped, which allows headers to be present in a CSV file but not used.Ideally, one should be able to provide headers in a text block when using
@CsvSource
or in a file when using@CsvFileSource
, and these headers can be used when generating the display name for each invocation of the@ParameterizedTest
.Proposal
This feature can be implemented using the
Named
API to associate each column value with its corresponding header.Given the following parameterized test that sets
useHeadersInDisplayName
totrue
and uses{arguments}
instead of{argumentsWithNames}
for its display name pattern...The generated display names are:
The text was updated successfully, but these errors were encountered: