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

Better support for comparing multi-line strings #402

Closed
sschuberth opened this issue Sep 11, 2018 · 1 comment
Closed

Better support for comparing multi-line strings #402

sschuberth opened this issue Sep 11, 2018 · 1 comment
Labels
enhancement ✨ Suggestions for adding new features or improving existing ones.
Milestone

Comments

@sschuberth
Copy link
Member

When doing

actualResult shouldBe expectedResult

where both actualResult and expectedResult are (long) multi-line strings, console output in case of a mismatch could be improved. Currently, as can be seen e.g. here, console output starts with the expected text. However, as that text is long and console output is limited, it does not even come as far as also showing the actual output. To address this, it would be nice if long multi-line output was condensed by stripping matching lines, and only keeping "diff hunks" similar like Git does to display only the areas of text where there actually is a difference.

@sksamuel sksamuel added this to the 3.2 milestone Sep 11, 2018
@sksamuel sksamuel added the enhancement ✨ Suggestions for adding new features or improving existing ones. label Sep 11, 2018
@sksamuel sksamuel mentioned this issue Nov 26, 2018
17 tasks
@sksamuel
Copy link
Member

sksamuel commented Dec 2, 2018

I've added my attempt.

You end up with a sequence of diffs. Each diff has a type (delete, change, addition), the line where it started, and the snippet that changed (with a line before/after for context).

The raw exception message is like this:

java.lang.AssertionError: 
expected: "[Change at line 1] Our neural pathways have become accustomed to your sensory input patterns.
      Mr. Crusher, ready a collision course with the Borg ship.
      A lot of things can change in twelve years, Admiral.

[Deletion at line 4] A lot of things can change in twelve years, Admiral.
      Take the ship into the Neutral Zone"

 but: was "[Change at line 1] Our neural pathways have become accustomed to your sensory input patterns.
      Mr. Crusher, ready a collision course with the Klingon ship.
      A lot of things can change in ten years, Admiral.

[Deletion at line 4] A lot of things can change in ten years, Admiral."

Which intellij picks up nicely and shows the diff window.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ Suggestions for adding new features or improving existing ones.
Projects
None yet
Development

No branches or pull requests

2 participants