You need to sign in to do that
Don't have an account?
Chitral Chadda
only when do not market = blacklisted then it performs action
do not mail =true;
email opt out = true;
but with this test class initiall i inserted do not market = DNC this season
and then when i change do not market = blacklisted
and test code
i get error ....System.AssertException: Assertion Failed: Expected: true, Actual: false at line 24
if i do like
i get 100 % coverage...
but these fields should be set to true when do not market = blacklisted .
test class
trigger LeadUpdate on Lead (before Update) { //list<lead> addhere = new list<lead>(); for( lead ld :trigger.new) { if(ld.Do_Not_Market__c=='Blacklisted' && trigger.oldmap.get(ld.id).Do_Not_Market__c!= 'Blacklisted') { //Lead renewal = new lead(); ld.Do_Not_Mail__c=True; ld.DoNotCall=True; ld.Email_Opt_Out__c=True; ld.Status='Dead'; ld.LastName=ld.Lastname +'Renewal'; ld.Company='ABC'; //addhere.add(renewal); } } //insert addhere; }
only when do not market = blacklisted then it performs action
do not mail =true;
email opt out = true;
but with this test class initiall i inserted do not market = DNC this season
and then when i change do not market = blacklisted
and test code
i get error ....System.AssertException: Assertion Failed: Expected: true, Actual: false at line 24
@isTest public class testLeadUpdate { static testMethod void updatelead() { lead ld = new lead(); //ld.Do_Not_Market__c='DNC This Season'; //ld.Do_Not_Mail__c=false; //ld.Email_Opt_Out__c=false; //ld.LastName='Renewal'; //ld.Company='ABC'; ld.Do_Not_Market__c='DNC This Season'; ld.LastName='Renewal'; ld.Company='ABC'; insert ld; system.assertEquals(false,ld.Do_Not_Mail__c);//line 24 system.assertEquals(false,ld.Email_Opt_Out__c); ld.Do_Not_Market__c='Blacklisted'; update ld; system.assertEquals(true,ld.Do_Not_Mail__c); system.assertEquals(true,ld.Email_Opt_Out__c); } }
if i do like
@isTest public class testLeadUpdate { static testMethod void updatelead() { lead ld = new lead(); ld.Do_Not_Market__c='DNC This Season'; ld.LastName='Renewal'; ld.Company='ABC'; insert ld; system.assertEquals(false,ld.Do_Not_Mail__c); system.assertEquals(false,ld.Email_Opt_Out__c); ld.Do_Not_Market__c='Blacklisted'; update ld; system.assertEquals(false,ld.Do_Not_Mail__c); system.assertEquals(false,ld.Email_Opt_Out__c); } }
i get 100 % coverage...
but these fields should be set to true when do not market = blacklisted .
I tried at my end and got to know that we should use Query after update.
try the below code now.
All Answers
Try with the below code.
Use true at Line 20, 21 instead of false.
use the below one.
i get error
System.AssertException: Assertion Failed: Expected: true, Actual: false line 20
Make sure that your trigger is firing by creating a lead record.
yes trigger works .
if do not market = dnc this season then the fields are not checked
if i select do not market as blacklisted then fields are checked
I tried at my end and got to know that we should use Query after update.
try the below code now.
we queried first and then updated the record naturally it wud b false if we do this way
thnx