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

AssertArrayEquals - show a more useful error message when failing #1471

Closed
dylan-chong opened this issue Jun 27, 2017 · 2 comments
Closed

AssertArrayEquals - show a more useful error message when failing #1471

dylan-chong opened this issue Jun 27, 2017 · 2 comments

Comments

@dylan-chong
Copy link

dylan-chong commented Jun 27, 2017

With the code

assertArrayEquals(new int[]{1,2,3}, new int[]{2,3,4,5});

I get the error message

java.lang.AssertionError: array lengths differed, expected.length=3 actual.length=4

But this doesn't tell me much about why it failed - if the length is wrong, then what are the extra values?

I would rather see an error message that shows both array contents:

java.lang.AssertionError: 
Expected :[1, 2, 3]
Actual   :[2, 3, 4, 5]

Which is actually what you get when you convert your arrays to lists first.

assertEquals(Arrays.asList(1,2,3), Arrays.asList(2,3,4,5));

Could the output format be changed to show both the contents of both arrays?

@kcooney
Copy link
Member

kcooney commented Jun 28, 2017

It looks like this was fixed by #1300

@dylan-chong can you confirm that the above pull fixes your issue?

@dylan-chong
Copy link
Author

Ah yes that looks like it fixes this issue. Thanks.

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