-4
Contact jane = new contact(FirstName='Jane',LastName='Smith', Email='jane.smith@example.com', Description='Contact of the day');
insert jane;
Contact Jane2 = new contact(FirstName='Jane',LastName='Smith', Email='jane.smith@example.com', Description='Prefers to be contacted by email.');
upsert jane2 contact.fields.Email;
System.assertEquals('prefers to be contacted by email.', [SELECT Description FROM Contact WHERE Id=:Jane.Id].Description);
  • when i execute i'm getting the error like System.AssertException: Assertion Failed: Expected: prefers to be contacted by email., Actual: Prefers to be contacted by email. – Kumar praveen Nov 12 at 21:03
  • Please place your question or problem statement in the body of your question, not in a comment. You can make an edit to do this. – David Reed Nov 12 at 21:05
  • The error message tells you the difference. Simply change your hard coded URL to match exactly what your'e setting the description to. – Kris Goncalves Nov 12 at 21:06
  • 4
    Your issue is where you are trying to assert prefers... with Prefers.... System.assertEquals(..) checks for equality and in this case the two strings are not. – Jayant Das Nov 12 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.