-
Notifications
You must be signed in to change notification settings - Fork 1k
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
assertEquals(set,set) now requires same ordering which it didn't before #2643
Comments
another reason why this behavior change is weird is because there are already another method that does a element order comparison: having to differently named methods doing the same thing is ofcourse very confusing. |
@Elisedlund-ericsson - One of the reasons behind this change is attributed to #2540 Please take a look at that. The behaviour was changed in the master because of the afore-mentioned defect. @juherr - Suggestions ? |
which cases issue #2540 thanks to behavior change as it alters test case results.
causing a regression again but the other way around. Personally I think the change nr 2.) you did to use Objects.equals() for Collections is actually is actually to most logical
javadoc of Set.iterator:
even meaning that the same set instance could technically give different order every time. Going for nr 2.) which I think is the most logical solution unfortunately it causes regression issues OpenJDK (and forsure others) meaning that the best solution is probably to stick with the original behavior 1.) |
@Elisedlund-ericsson would you be willing to propose a fix for this via a pull request ? |
sorry for the delay. there should now exist an pullrequest fixing this issue, |
In TestNG 7.4.0(and all previous versions?) the following example worked fined and both sets where considered equal.
the AbstractSet.equals() implementation in Java and used by most Set implementations define equality as the two sets containing the same elements but not necessarily in the same order.
on the latest master of TestNG however the above example no longer works and throws:
"java.lang.AssertionError: Iterators not same element order: expected: 1 and actual: 2"
the line causing this issue is:
https://github.com/cbeust/testng/blob/cd85bcb7afebbaecd2299cbc72632e27f89a441b/testng-asserts/src/main/java/org/testng/Assert.java#L1459
which now iterates both sets and require the same ordering.
as Objects.equals(actual, expected) is already know to be true it would have made more sense to just return true instead. (so it functions as before.
It also makes more sense for TestNGs assertEquals(set,set) to align with Java's definition of set.equals(set) as it was before.
also even the comment in the same methods implies that you don't want to check ordering:
https://github.com/cbeust/testng/blob/cd85bcb7afebbaecd2299cbc72632e27f89a441b/testng-asserts/src/main/java/org/testng/Assert.java#L1447
The text was updated successfully, but these errors were encountered: