I have methods in my class that return a single item from a SOQL using the items Id.
return [SELECT Id, OwnerId, IsDeleted, Name, CreatedDate, LastModifiedDate, CreatedById, LastModifiedById, SystemModstamp, TouchpointDev__PersonalItem__c, TouchpointDev__AssignedTo__r.Name, TouchpointDev__Completed__c, TouchpointDev__CompletedBy__r.Name, TouchpointDev__Completed_Date__c, TouchpointDev__High_Priority__c, TouchpointDev__Display__c, TouchpointDev__Item_Due_Date__c, TouchpointDev__Activities__c, TouchpointDev__Past_Due__c, TouchpointDev__Trashed__c
FROM TouchpointDev__Whiteboard_Item__c
WHERE Id =: whiteboardItem.Id];
Changing the return value from the argument used in the method, it now breaks all my test classes. Even though the values all match, they are just out of of order and also have some extra fields that belong to the object.
How would I make my test pass?
System.AssertException: Assertion Failed:
Expected: TouchpointDev__Whiteboard_Item__c:{Name=Test Item 1, TouchpointDev__Item_Due_Date__c=2016-08-18 00:00:00, TouchpointDev__AssignedTo__c=005d0000006FYTqAAO, TouchpointDev__High_Priority__c=false, TouchpointDev__PersonalItem__c=true, TouchpointDev__Completed__c=false, Id=a00d000000k2s8ZAAQ},
Actual: TouchpointDev__Whiteboard_Item__c:{Id=a00d000000k2s8ZAAQ, OwnerId=005d0000005NR4WAAW, IsDeleted=false, Name=Test Item 1, CreatedDate=2016-08-18 21:46:09, LastModifiedDate=2016-08-18 21:46:09, CreatedById=005d0000005NR4WAAW, LastModifiedById=005d0000005NR4WAAW, SystemModstamp=2016-08-18 21:46:09, TouchpointDev__PersonalItem__c=true, TouchpointDev__AssignedTo__c=005d0000006FYTqAAO, TouchpointDev__Completed__c=false, TouchpointDev__High_Priority__c=false, TouchpointDev__Display__c=false, TouchpointDev__Item_Due_Date__c=2016-08-18 00:00:00, TouchpointDev__Activities__c=0, TouchpointDev__Past_Due__c=false, TouchpointDev__Trashed__c=false}
SObject
equality. At best, it's silly. It's certainly not a tenable strategy in most cases. – Adrian Larson♦ Aug 18 '16 at 22:42