In my tests I create an object and compare it to the one returned in the function using System.assertEquals. Despite all the properties being exactly the same I still get the "Assertion Failed" message when comparing objects. 

Message: 
System.AssertException: Assertion Failed: Expected: Attribute:[name=Name, options=null, required=false, showInUI=true, type=String, value=], Actual: Attribute:[name=Name, options=null, required=false, showInUI=true, type=String, value=]

Notice that Expected and Actual are exactly the same.