You need to sign in to do that
Don't have an account?
halopez
Asserting equality in custom classes.
Hi all,
I have the following error:
System.AssertException: Assertion Failed: Expected: ProductModelController:[contents=12345, creator=cchap@testconfigit.com, name=AltivarSample.configuration, referencePM=SEP_ATVCBL_V14_CTO.vt, visibility=true], Actual: ProductModelController:[contents=12345, creator=cchap@testconfigit.com, name=AltivarSample.configuration, referencePM=SEP_ATVCBL_V14_CTO.vt, visibility=true]
What I am doing in the test is simply creating two objects and comparing them. The code coverage hits the equals() method in the class, but when I am trying to assert whether two custom objects are the same, apex fails.
Is it just me, or that should be an error in the Apex compiler?
Cheers,
HA
I concur that it does not operate as expected:
It appears that System.assertEquals ignores Object.equals and Object.hashCode (the two functions required to use custom objects as keys in sets/maps). You'll have to use the former method, not the latter, for now.