I have an after insert/update trigger that on an object called Call_Report__c
. The after trigger (upon save) sets the field of the Call_Report__c
object. I'm not sure how to test it since I don't know how to make sure the trigger is being fired. I saw something on trailhead Database.Delete Result = Database.delete(acct, false)
but can this apply in my situation? Is there one for update
and insert
? How do I distinguish before/after?
This is what I have so far for my test:
@isTest
public with sharing class CallReportTriggerTest {
@isTest static void testSetFieldsMethod() {
Call_Report__c callReport = new Call_Report__c();
callReport.Loan_Apps_to_Relate__c = 'a071F00000A99Z4QAJ,a071F00000A99YpQAJ';
Loan_Application__c loanAppRelate = new Loan_Application__c(Id = 'a071F00000A99Z4QAJ');
Loan_Application__c loanAppRelate1 = new Loan_Application__c(Id = 'a071F00000A99YpQAJ');
insert callReport;
System.assertEquals(callReport.Id, loanAppRelate.Call_Report__c);
System.assertEquals(callReport.Id, loanAppRelate1.Call_Report__c);
}
}
Currently the tests fail saying actual is null
.