-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
Overview
When using @CsvSource
, CSV headers are not supported. With @CsvFileSource
, the first n
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
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