Given a simple test-method, annotated as @ParameterizedTest
, employing input via Annotation @CsvSource
(e.g.@CsvSource({ "@", "*", "#", "?", "-", "$", "!", "0" }
). When running said test, the test interrupts as soon as "#"
is supposed to be tested. When reading through the stacktrace/exception, I found the following:
org.junit.jupiter.params.shadow.com.univocity.parsers.common.TextParsingException: java.lang.IllegalArgumentException - Unable to skip 1 lines from line 2. End of input reached
Parser Configuration: CsvParserSettings:
...
CsvFormat:
Comment character=#
Field delimiter=,
Line separator (normalized)=\n
Line separator sequence=\r\n
Quote character='
Quote escape character='
Quote escape escape character=null
I guess the problem is in the last block (Comment character=#
): The specific parameter is being read as comment. How do I change this setting?
You cannot change the comment character.
You could wrap the #
in single quotes like this:
@CsvSource({ "@", "*", "'#'", "?", "-", "$", "!", "0" })
But you actually shouldn't be using @CsvSource
for single strings anyway.
Instead, simply use the following:
@ValueSource(strings = { "@", "*", "#", "?", "-", "$", "!", "0" })