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

Fix for #803: improve error message for assertArrayEquals() when multi-dimensional arrays have different lengths #1054

Closed
wants to merge 2 commits into from
Closed

Fix for #803: improve error message for assertArrayEquals() when multi-dimensional arrays have different lengths #1054

wants to merge 2 commits into from

Conversation

Stephan202
Copy link
Contributor

This is an implementation of the suggestion made in #803. Please note that the two new unit tests may make obsolete part of (but certainly not all of) PR #804.

Previously, JUnit's assertion error message would indicate only that some array
lengths x and y were unequal, without indicating whether this pertained to the
outer array or some nested array. Now, in case of a length mismatch between two
nested arrays, Junit will tell at which indices they reside.
} catch (ArrayComparisonFailure e) {
e.addDimension(i);
throw e;
} catch (AssertionError e) {
throw new ArrayComparisonFailure(header, e, i);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment here: // array lengths differed

@kcooney
Copy link
Member

kcooney commented Dec 28, 2014

@Stephan202 Thanks for putting this together so quickly!

It's possible that changing this message might break someone, so I would prefer that this pull be made against the junit5 branch. I suggest we made the changes above, and once it looks fine, I'll ask you to create a new pull against the junit5 branch and cherrypick this change there. I'll work on getting PR #804 merged into master and then merged into junit5 so we can resolve the merge conflicts now.

- Added comments explaining edge cases.
- Reworked assertion statements in new unit tests.
@Stephan202
Copy link
Contributor Author

@kcooney, thanks for the feedback. I have made an additional commit. We'll squash it once done.

(I actually intended to open the PR against the junit5 branch, as you asked in #803... guess I screwed up.)

@kcooney
Copy link
Member

kcooney commented Dec 29, 2014

@junit-team/junit-committers it's possible (though unlikely) that someone is trying to parse the error messages in a way that would be broken by this change. Do you guys feel comfortable including this in 4.13, or should we commit this against the junit5 branch? (yes, I realize that we may decide to skip 4.13, but let's assume for now that we might release 4.13)

@kcooney kcooney changed the title Fix for #803: make clearer *which* nested arrays have unequal length. Fix for #803: improve error message for assertArrayEquals() when multi-dimensional arrays have different lengths Dec 29, 2014
@marcphilipp
Copy link
Member

+1 for including this in 4.13

@dsaff
Copy link
Member

dsaff commented Dec 30, 2014

I'm OK with including this in 4.13, with the idea that we would back it out
if anyone yelps during the beta.
On Dec 28, 2014 8:26 PM, "Kevin Cooney" notifications@github.com wrote:

@junit-team/junit-committers
https://github.com/orgs/junit-team/teams/junit-committers it's possible
(though unlikely) that someone is trying to parse the error messages in a
way that would be broken by this change. Do you guys feel comfortable
including this in 4.13, or should we commit this against the junit5 branch?
(yes, I realize that we may decide to skip 4.13, but let's assume for now
that we might release 4.13)

Reply to this email directly or view it on GitHub
#1054 (comment).

@stefanbirkner
Copy link
Contributor

+1 for including this in 4.13

@kcooney kcooney closed this in 3f0adea Jan 4, 2015
@kcooney
Copy link
Member

kcooney commented Jan 4, 2015

Sqashed commits and merged into master. Thanks!

@kcooney
Copy link
Member

kcooney commented Jan 4, 2015

@Stephan202 could you update the 4.13 release notes to mention this change? Thanks again!

@Stephan202 Stephan202 deleted the clearer-nested-array-lengh-assertion-message branch January 4, 2015 20:17
@Stephan202
Copy link
Contributor Author

Done :)

@stefanbirkner stefanbirkner added this to the 4.13 milestone Apr 13, 2015
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

Successfully merging this pull request may close these issues.

5 participants