You need to sign in to do that
Don't have an account?

System.assertEquals on SObjects
I'm trying to compare two SObjects (Accounts in this example) in a unit test using System.assertEquals, but the assertion fails every time. The SObjects have the same field values so it should come back true, right? Here is the assert exception:
FATAL_ERROR|System.AssertException: Assertion Failed: Expected: Account:{NumberOfEmployees=10, Name=testAcc0, Description=Test Account, BillingCity=TestCity, BillingPostalCode=90210, BillingStreet=0 main st., Id=001A000000H632WIAR, AnnualRevenue=1000000.55, BillingState=TestState}, Actual: Account:{Name=testAcc0, NumberOfEmployees=10, Description=Test Account, BillingCity=TestCity, BillingPostalCode=90210, BillingStreet=0 main st., Id=001A000000H632WIAR, AnnualRevenue=1000000.55, BillingState=TestState}
The only thing I see is the order of the fields but that should not make a difference.
Sounds like a bug. If you can give me some isolated code that reproduces it, I can take a look.
A workaround in your case would be to assert that the IDs are the same, instead of the sobjects.
Rich