function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Prashant Kumar 438Prashant Kumar 438 

getting error in the test class -> I have to match the date and time field of both interview object and the interview_Slot object show trigger fire.

System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Choose Appropriate Date/Time: [Interview_Date_and_Time__c]

@isTest(seeALLData = true)
public class InterviewerSlotBatch_TestClass {
    @isTest
    public static void InterviewerSlotBatch_TestMethod(){
        
        List<Contact> conList = [SELECT Id, Name, Interviewer__c FROM Contact];
        List<Interviewer_Slot__c> slots = new List<Interviewer_Slot__c>();
        
        Interviewer_Slot__c intSlot = new Interviewer_Slot__c(Date__c = Date.today(), Start_Time__c = Time.newInstance(3, 14, 15, 926), End_Time__c 
                                                              = Time.newInstance(4, 0, 0, 926), Contact__c = conList[0].Id);
        
        
        slots.add(intSlot);
        insert slots;
        test.startTest();
        InterviewerSlotBatch InterviewerSlotBatch_TestClass = new InterviewerSlotBatch();
        Database.executeBatch(InterviewerSlotBatch_TestClass);
        test.stopTest();
    }
}
AnudeepAnudeep (Salesforce Developers) 
Hi Prashant, 

Do you have any validation rules on the interview object or interview_Slot object with the message "Choose Appropriate Date/Time"? 

Anudeep