Skip to content

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

Closed

Description

@Philzen

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.

Activity

  1. juherr commented on Jun 22, 2024

    @juherr
    Member

    Thanks for the report.

    Could you propose a fix in a pull request ?

  2. added this to the 7.11.0 milestone on Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions