You need to sign in to do that
Don't have an account?
Admin User 10568
How to test next business hour trigger
Hi,
I would like to write a test to understand if a next business date/time trigger is updating a field. I'm trying to test by inserting a new lead and then compare its next task start time (next business date/time) is the same as the systems next business date/time. At the minute the console is returning:"Comparison arguments must be compatible types: Datetime, REPRO__Lead__c". Wondering if anyone has a resource or an idea on how can get this working?
I would like to write a test to understand if a next business date/time trigger is updating a field. I'm trying to test by inserting a new lead and then compare its next task start time (next business date/time) is the same as the systems next business date/time. At the minute the console is returning:"Comparison arguments must be compatible types: Datetime, REPRO__Lead__c". Wondering if anyone has a resource or an idea on how can get this working?
@isTest public class NextAvailableBusinessMomentTest{ @isTest private static void newLeadTaskStartTimeTest(){ REPRO__Lead__c ld = new REPRO__Lead__c(); ld.REPRO__First_Name__c = 'Homer'; ld.REPRO__Last_Name__c = 'Simpson'; ld.REPRO__Email__c = 'hsimpson@springfieldmail.com'; ld.Name = 'Homer Simpson - Time Check'; Test.startTest(); //Insert the above RP custom lead field values insert ld; //Get the default business hours Id businessHourId = [SELECT Id FROM BusinessHours WHERE IsDefault = true].Id; //Get the next date when business hours are open. If the specified target date falls within business hours, this target date is returned. Datetime targetDate = system.today(); Datetime nextDate = BusinessHours.nextStartDate(businessHourId, targetDate); //Get Task Start Time created by Next Available Business Moment triggered before inserted lead created REPRO__Lead__c updatelead = [Select Task_Start_Time__c FROM REPRO__Lead__c where Id =: ld.Id]; //expected vs actual system response for next task completed task time System.assertEquals(nextDate, updatelead); Test.stopTest(); } }
//expected vs actual system response for next task completed task time
//System.assertEquals(nextDate, updatelead);
// Missing .Task_Start_Time__C
// Answer
System.assertEquals(nextDate, updatelead.Task_Start_Time__c);