In my batch class, there is a condition that checks
if(Opp.lastactivitydate != null || (Opp.LastModifiedDate > Opp.CreatedDate && Date.ValueOf(Opp.LastModifiedDate) <= Opp.renew_opp_reminder__c))
I want to know how to create test data for an opportunity that has LastActivityDate != null
I have tried:
//setup
Account accttest = new Account(
Name = 'TestAcc',
Company_English__c = 'TestComp',
DBD_ID__c = '12345',
Tax_ID__c = '-'
);
insert accttest;
Opportunity opptest = new Opportunity(
Name = 'Test opp ',
CloseDate = System.today().addMonths(1),
Policy_Effective_Date__c = System.today(),
Renew_Opp_Reminder__c = System.today(),
AccountId = accttest.Id,
StageName = 'Qualification',
Renew_From_Lost__c = true,
Catch_Up_Noti_Send__c = true
);
insert opptest;
I can't add LastActivityDate = System.today() because the field is not writeable. Please help me.