ParameterizedTest with @CsvSource
This lesson demonstrates the use of @CsvSource to pass different arguments to @ParameterizedTest.
We'll cover the following
@CsvSource
@CsvSource
allows you to provide parameter lists as comma-separated custom-delimiter separated values. @CsvSource
annotation uses single quote along with comma-separated delimiter to distinguish a csv value from others.
For e.g -
- {“one, two”} will result to 2 arguments as - “one”, “two”.
- {“one, ‘two, three’”} will result to 2 arguments as - “one”, “two, three”.
- {“one, ‘’”} will result to 2 arguments as - “one”, “”.
- {"one, "} will result to 2 arguments as - “one”, null.
Let’s look at a demo.
Step 1 - Let’s assume that we have to write a parameterized test that takes values from @CsvSource
.
Get hands-on with 1400+ tech skills courses.