You need to sign in to do that
Don't have an account?
Two lines not covered in Test class
Hi All,
I'm trying to write a test class to this class below. But I'm not able to cover lines 12 & 20. Can someone help me out please?
Avinash
I'm trying to write a test class to this class below. But I'm not able to cover lines 12 & 20. Can someone help me out please?
trigger orientationDateUpdate on Registrations__c (before insert, before update) { if(Trigger.isInsert && Trigger.isBefore) { for(Registrations__c temp : Trigger.new) { if(temp.Planned_Orientation_Date__c == null) { Date date1 = Date.newinstance(1900,1,7); Date date2 = Date.TODAY(); if(date2.day()<7 && math.MOD(date1.daysBetween(date2),7) != 0 && math.MOD(date2.month(),2) != 0) { date2 = date2.addDays(7-math.MOD(date1.daysBetween(date2),7)); } else { date2 = Date.newInstance(date2.year(), math.MOD(date2.month(),2) != 0 ? date2.month()+2 : date2.month()+1 , 1); if(math.MOD(date1.daysBetween(date2),7) != 0) date2 = date2.addDays(7-math.MOD(date1.daysBetween(date2),7)); } system.debug('******Planned Orientation Date ***** ' + date2 ); temp.Planned_Orientation_Date__c = date2; } } } }Thanks in Advance,
Avinash
My first instinct is that you don't have a method in your test class that triggers the 'True' of the two IF Statements immediately proceeding your untested code. Add two more methods which will allow for those lines to run and you should get your coverage.
If this doesn't help, please post your test class.
If this does help, please select this answer as the best.
Cordially,
Matthew Velez
All Answers
My first instinct is that you don't have a method in your test class that triggers the 'True' of the two IF Statements immediately proceeding your untested code. Add two more methods which will allow for those lines to run and you should get your coverage.
If this doesn't help, please post your test class.
If this does help, please select this answer as the best.
Cordially,
Matthew Velez