Closed adam07018 closed 1 year ago
assertFalse(AB1 == AB2)
should compare the references.
However I think a combination of both would be better. One to compare if they are different references and the other to check if they have the same state.
assertFalse(AB1 == AB2)
assertEquals(AB1, AB2)
Answer is found
Basically, I use a clone method to deep copy the Addressbook.
For example, AB2 = AB1.clone(); AB2 and AB1 has same userList but they got different reference.
Thus, If I write AssertNotEquals(AB1, AB2), it should pass test.
However, I found out that there is a equal method overloaded in Addressbook class which make my AssertNotEquals fail. Because equal method in Addressbook will return true if their userList are same.
Is there anyway to bypass the overload equal and let test method (use the java object equal) directly compare their reference?