javaunit-testingjunit5junit-jupiter

How to pass a space as value in @CsvSource


Cannot figure out the syntax to pass a space as a value in jupiter's @CsvSource

@ParameterizedTest
@CsvSource({
                " ,lastName"
})
void test(String firstName, String lastName) {
...
}

but firstName is null and not a space character. Is it doable at all with this annotation?


Solution

  • Figured it out. I had to surround the space with single quotation marks as shown below:

    @CsvSource({
                    "' ',lastName"
    })