0

When using @ParametrizedTest in Junit 5 with @CsvFileSource, i need a parameter containing double quotes. How do I escape these, i.e. how do i pass exatly "a test" as my parameter?

What I have tried:

"a test"
""a test""
\"a test\"
"\"a test\""

What the parameter is converted to:

a test
""a test""
\"a test\"
"\"a test\""
user2727133
  • 149
  • 1
  • 12
  • 1
    https://tools.ietf.org/html/rfc4180 – markspace May 29 '20 at 23:57
  • The second and fourth ones are spec violations, but I'm also surprised the reader interpreted the string that way. I'm also surprised the second one and the fourth one didn't concatenate two fields together. – markspace May 30 '20 at 00:02

1 Answers1

0

Thanks to @markspace's comment, I noticed the problem is not Junit 5, but the CSV standard. So I tried editing it in LibreOffice instead of a text editor, which gave me the answer:

"""a test"""

result:

"a test"
user2727133
  • 149
  • 1
  • 12