You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assertNotSame(object1, object2) should pass, when object1 != object2 && object1.equals(object2)
Actual behavior
After merging 841ae94 (issue #2460) it looks like replacing actual==expected / actual!=expected to equals/ !equals went too far and broken one of common Assetions. Its a strong backward incompatible change in behaviour between 7.3 and 7.4
Is the issue reproductible on runner?
(Probably everywhere, tested on two)
Shell
Maven
Gradle
Ant
Eclipse
IntelliJ
NetBeans
Test case sample
Please, share the test case (as small as possible) which shows the issue
Problem is present for any custom object which has implemented its own equals method.
import java.util.Objects;
import org.testng.Assert;
import org.testng.annotations.Test;
public class BrokenNotSameTest {
static class MyObject {
private final String myName;
MyObject(String myName) {
this.myName = myName;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MyObject myObject = (MyObject) o;
return Objects.equals(myName, myObject.myName);
}
@Override
public int hashCode() {
return Objects.hash(myName);
}
}
@Test
public static void assertNotSamePass73Fails74() {
MyObject instance1 = new MyObject("someName");
MyObject instance2 = new MyObject("someName");
Assert.assertNotSame(instance1, instance2);
}
@Test
public static void assertSameInstancesFails73Pass74() {
MyObject instance1 = new MyObject("someName");
MyObject instance2 = new MyObject("someName");
Assert.assertSame(instance1, instance2);
}
}
The text was updated successfully, but these errors were encountered:
TestNG Version 7.4
Expected behavior
assertNotSame(object1, object2) should pass, when
object1 != object2 && object1.equals(object2)
Actual behavior
After merging 841ae94 (issue #2460) it looks like replacing
actual==expected
/actual!=expected
toequals
/!equals
went too far and broken one of common Assetions. Its a strong backward incompatible change in behaviour between 7.3 and 7.4Is the issue reproductible on runner?
(Probably everywhere, tested on two)
Test case sample
Problem is present for any custom object which has implemented its own equals method.
The text was updated successfully, but these errors were encountered: