testng
testng copied to clipboard
assertEqualsDeep(Set, Set, String) fails when it shouldn't
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
https://github.com/testng-team/testng/blob/0f779fe8a565d5e1024f34bc49e8a1c3df1ed8a7/testng-asserts/src/main/java/org/testng/Assert.java#L2070-L2072
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
- [x] IntelliJ
- [ ] NetBeans
Probably everywhere.
Thanks for the report.
Could you propose a fix in a pull request ?