You need to sign in to do that
Don't have an account?
Ronaldo Costa
Test class - trigger to create child records
Hello,
Please review the code below, I don't get why its not passing 100%
Trigger:
Test class:
Thanks!
Please review the code below, I don't get why its not passing 100%
Trigger:
trigger CreateFlightItinerary on Opportunity (after update) { List<Itinerary__c> fi = new List<Itinerary__c>(); for (Opportunity a: Trigger.New) if (a.fi_automation_check__c == TRUE){ <b>fi.add (new Itinerary__c(</b> Flight_Booking__c = a.Id, Stop_1__c = a.Stop1_ID__c, Flight_Crew_1__c = a.CrewM_1_ID__c )); } insert fi; }
Test class:
@isTest private class testCreateFlightItinerary{ static TestMethod void myTestClass() { Account a = new Account(); a.Name = 'TestName'; a.Phone = '5512991224391'; insert a; Opportunity o = new Opportunity(); o.Name = 'TestName'; o.AccountID = a.Id; o.closedate = system.today(); o.stagename = 'Sample Quote'; o.Aircraft_Type__c = 'King Air'; o.fi_automation_check__c=false; insert o; o.fi_automation_check__c=true; update o; } }
Thanks!
You have to set o.fi_automation_check__c to true in test class. line 16
And after insert opportunity, you need to check if itinerary__c record is inserted (cover line 5 to 8 in trigger).
You can use the following code to cover 100% code.
BTW, I would suggest change the trigger at line 11:
if (fi.size() > 0)
insert fi;
Try After changing
to Hope this will fix your issue.
However it still at 80%, any thoughts? Same line uncovered...
Thanks very much.
o.fi_automation_check__c=true;
Any ideas? How can I make sure it created the Itinerary record? I will modify the code one more time and try it again.
You don't need code from line 33 to line 42.
fi.add (new Itinerary__c(
not covered...
Any additional ideas??