Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warn if a CharSequence.contains and the like did not match because of different line endings #834

Open
robstoll opened this issue Mar 16, 2021 · 5 comments

Comments

@robstoll
Copy link
Owner

robstoll commented Mar 16, 2021

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.
@jGleitz
Copy link
Collaborator

jGleitz commented Mar 17, 2021

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 using System.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

@robstoll
Copy link
Owner Author

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 :)

@jGleitz
Copy link
Collaborator

jGleitz commented Mar 17, 2021

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

@robstoll
Copy link
Owner Author

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 expected Hello World\n

how about:
if you had used \r\n instead of \n in the expected string

@jGleitz
Copy link
Collaborator

jGleitz commented Mar 18, 2021

if you had used \r\n instead of \n in the expected string

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants