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

GitHub 2913 #2914

Merged
merged 4 commits into from
May 30, 2023
Merged

GitHub 2913 #2914

merged 4 commits into from
May 30, 2023

Conversation

ahgittin
Copy link

@ahgittin ahgittin commented May 25, 2023

Fixes #2913 .

Did you remember to?

  • Add test case(s)
  • Update CHANGES.txt
  • Auto applied styling via ./gradlew autostyleApply

@ahgittin
Copy link
Author

Test case checkMapNotEqualsWithNull added failing in 7a4394b passing once fixed applied in 4216a3d .

/* expected */
}
if (succeeded) {
Assert.fail("Maps reported as not equal when equal: " + m1 + " / " + m2);
Copy link
Member

Choose a reason for hiding this comment

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

Could be replaced but assertFalse

assertEquals(m1, m2);

boolean succeeded = false;
try {
Copy link
Member

Choose a reason for hiding this comment

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

can we refactor this to

try {
     assertNotEquals((Object) m1, (Object) m2);
    Assert.fail("Maps reported as not equal when equal: " + m1 + " / " + m2);
} catch (AssertionError ignored) {}

This will do away with the extra variable succeeded

Copy link
Author

Choose a reason for hiding this comment

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

I like the var name instead of the comment -- I've called it expected.

However putting the Assert.fail call inside the try will cause the AssertionError that it throws to be ignored, won't it?, and that defeats the point of the test. I don't know of a simple way to avoid the ugly succeeded, apart from introducing lambdas or splitting up the test and using expectedExceptions or checking the body of the failure message -- all of which I think are worse. (But I don't feel at strongly and this is your codebase so LMK if you prefer something different!)

Copy link
Author

Choose a reason for hiding this comment

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

(gradle insists on putting a newline between the {} but it saves a bit of bloat)

Copy link
Member

Choose a reason for hiding this comment

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

You can try {} //

Copy link
Member

Choose a reason for hiding this comment

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

@ahgittin - Sigh! my bad. Yes you are correct.

CHANGES.txt Outdated
@@ -1,5 +1,7 @@
Current

Fixed: GITHUB-2913: Maps containing nulls can be incorrectly considered equal
Copy link
Member

Choose a reason for hiding this comment

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

@ahgittin It would be good if you could please help add your ID/name at the end of this line, so that we can call out your contribution in the release notes of this version (when it goes out). Its our small way of thanking you for helping TestNG become better.

@ahgittin
Copy link
Author

All applied - TY

@juherr juherr merged commit 38279c6 into testng-team:master May 30, 2023
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.

Maps containing nulls can be incorrectly considered equal
3 participants