You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assertions.assertEqual formats an error when an assertion is false, this is great but in case of lists it is not very readable (and the diff when you click the error in idea is worse).
What could help is that if the instances are collections or arrays to format one item per line, would make it easier to read IMHO.
The text was updated successfully, but these errors were encountered:
I'm interested in working on this, since a vertical format can be quite useful when comparing lists, especially when the elements are of varying lengths. Although, it's probably not a good idea to modify the existing style of error output.
For reference, the existing output looks like this:
expected: <[short, a longer string, even longer string that is annoying]> but was: <[i am a small, i am not so small, tiny]>
Expected :[short, a longer string, even longer string that is annoying]
Actual :[i am a small, i am not so small, tiny]
I think a good solution would be to expose some static factory methods that return a Supplier<String> that formats the output in a desired format. So a user could do something like: assertEquals(CollectionA, CollectionB, OutputFormat.ofVertical(CollectionA, CollectionB));
This wouldn't affect any existing user tests/code and would also be flexible to adding new formats. I think it's also not that easy for users to implement the functionality on their own, since getting the spacing right can be tough. A quick Supplier<String> I wrote up looks like this:
expected | actual
short | i am a small
a longer string | i am not so small
even longer string that is annoying | tiny
But if this seems like a good idea, I could write it so that we get something like this:
expected | actual
short | i am a small
a longer string | i am not so small
even longer string that is annoying | tiny
(Would also need to handle stuff like unequal collection sizes, maybe including indexes, etc.)
This output would appear above the existing default output, so it does duplicate some information.
Assertions.assertEqual
formats an error when an assertion is false, this is great but in case of lists it is not very readable (and the diff when you click the error in idea is worse).What could help is that if the instances are collections or arrays to format one item per line, would make it easier to read IMHO.
The text was updated successfully, but these errors were encountered: