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

assertEqualsDeep(Set, Set, String) fails when it shouldn't #3140

Closed
1 of 7 tasks
Philzen opened this issue Jun 22, 2024 · 1 comment · Fixed by #3150
Closed
1 of 7 tasks

assertEqualsDeep(Set, Set, String) fails when it shouldn't #3140

Philzen opened this issue Jun 22, 2024 · 1 comment · Fixed by #3150

Comments

@Philzen
Copy link
Contributor

Philzen commented Jun 22, 2024

TestNG Version

Discovered on 7.5.1 and confirmed on 7.10.2

Expected behavior

assertEqualsDeep should probably have similar behaviour with Sets as with Maps.

This will pass:

Assert.assertEqualsDeep(
    Map.of("foo", new String[] {"foo"}, "map", Map.of()), 
    Map.of("foo", new String[] {"foo"}, "map", Map.of()), 
    "Not equal"
);

While this will not:

Assert.assertEqualsDeep(
    Set.of(new String[] {"foo"}, Map.of()), 
    Set.of(new String[] {"foo"}, Map.of()), 
    "Not equal"
);

Root cause

if (!areEqualImpl(value, expected)) {
return "Sets not equal: expected: " + expectedValue + " and actual: " + value;
}

This should probably be areEqualImpl(value, expectedValue) instead – expected is the whole Set and here it is compared with the current actual value from the iterator, which will always fail.

Is the issue reproducible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Probably everywhere.

@juherr
Copy link
Member

juherr commented Jun 22, 2024

Thanks for the report.

Could you propose a fix in a pull request ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants