You need to sign in to do that
Don't have an account?
helping testing cover code
I have a long trigger with many "if" where I don't know how to test it. This is one of the "if" which I don't know how to test...
list_opp is a list of id of opportunity and work properly, the trigger before update save the custom field sex of opportunity into the custom field of contact
if (list_opp.get(0).sex__c <> null){ c.sesso__c = list_opp.get(0).sex__c;}
I thinking to do this but doesn't work:
Account a = new account(name = 'Test ammin'); insert a; Contact c = new contact(lastname='test_last_name',accountid=a.id); insert c; Opportunity o = new Opportunity(name='Name test',sex = 'M'); insert o OpportunityContactRole z = new OpportunityContactRole(ContactId=c.id,OpportunityId=o.id,role='other',Isprimary=true); insert z; //now verify if sex is write properly Contact c2 = [select sex__c from contact where id=:c.id limit 1]; system.assertequals(o.sex__c,c2.sex__c);
the test say me:
System.Exception: Assertion Failed: Expected: M, Actual: null
thanks