You need to sign in to do that
Don't have an account?
Dosbol T
Help with test coverage for trigger
Please help with this test class, I cant get 100%, dont know how to improve it. Thanks,
Appreciate any support!
@isTest private class AutoPopDateTest { @isTest private static void AutoPopDate() { Billing__C bil = new Billing__C(); bil.Name = 'NewBill'; bil.Billing_Date__c = system.today(); bil.Accounting_date__c = bil.Billing_Date__c.addDays(20); try { insert bil; } catch (NullPointerException n) { } } }and trigger:
trigger AutoPopAccPerDate on Billing__c(before insert, before update) { for (Billing__c billing : Trigger.new) { if (billing.Accounting_Date__c == null) { billing.Accounting_Date__c = billing.Billing_Date__c.adddays(30); // '30 Days' - Depends on the terms. } } }
Appreciate any support!
You are checking for if (billing.Accounting_Date__c == null) then populate Accounting_Date__c but in test class you passing value for Accounting_Date__c so it is not entering in IF condition.
You can add one more record or comment out line bil.Accounting_date__c = bil.Billing_Date__c.addDays(20) then it should cover
All Answers
You are checking for if (billing.Accounting_Date__c == null) then populate Accounting_Date__c but in test class you passing value for Accounting_Date__c so it is not entering in IF condition.
You can add one more record or comment out line bil.Accounting_date__c = bil.Billing_Date__c.addDays(20) then it should cover