简体   繁体   中英

How to escape double qootes in Junit 5 a ParametrizedTest with CsvFileSource

When using @ParametrizedTest in Junit 5 with @CsvFileSource, i need a parameter containing double quotes. How do I escape these, ie 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\""

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM