atrium
atrium copied to clipboard
warn if a CharSequence.contains and the like did not match because of different line endings
Platform (all, jvm, js): all Extension (none, kotlin 1.3): none
Code related feature
Consider:
expect("Hello World\r\nMy name is Robert").contains("Hello World\n")
Currently results in the following error report:
expected that subject: "Hello World
My name is Robert" <558676967>
◆ contains:
⚬ value: "Hello World
It would be very helpful if Atrium pointed out that it would have matched if the user were using the correct line endings. So I imagine something like the following in the report:
expected that subject: "Hello World
My name is Robert" <558676967>
◆ contains:
⚬ value: "Hello World
"
🔎 Atrium detected that your expectation would have been met if you had used `\r\n` instead of `\n` in the expected string.
Consider using `System.lineSeparator` if your test runs on different operating systems.
I like the idea! With the following wording the message would be easier to understand for me:
Atrium detected that your expectation would have been met if you expected
\r\n
instead of\n
. Consider usingSystem.lineSeparator
if your test runs on different OS.
I also don’t know why we should suggest System.getProperty("line.separator")
when there is System.lineSeparator
Thanks for the hint about System.lineSeparator and the missing been
. However, I prefer used
over expected
. I have update the description and added the missing had
. I hope the sentence is now correct :)
My issue with ‘used’ is that it is ambiguous where \r\n
should have been used. Although not both interpretations are equally likely, the sentence could be read as
if you had used
\r\n
instead of\n
in the expectation
or as
if you had used
\r\n
instead of\n
in your production code
I see your point. The problem I see with expected
is that it might not be that obvious could be confusing in the sense of:
Why does Atrium tell me I have expected
\n
I have expectedHello World\n
how about:
if you had used \r\n
instead of \n
in the expected string
if you had used
\r\n
instead of\n
in the expected string
:+1: