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
Gyanaloka Panda 8Gyanaloka Panda 8 

Can anyone write the test class for the below apex class ..

public with sharing class HIV_ContactTriggerHandler{
public static void onBeforeInsert(List<Contact> lstContactNew,Boolean isInsert, Boolean isUpdate){
            Id hivAdminId ;
            hivAdminId = HIV_ApexSharing.getHIVAdminUserId();
            List<string> lstAcccntIds=new List<String>();
            List<String> lstRoles=new List<String>{Label.HIVProfilePTM,Label.HIVProfilePM,Label.HIV_OrganizationLead};
            for(Contact oContact : lstContactNew)
        }catch(Exception ex){
               Map<String, Object> mapErrorInfo = ERR_BaseErrorHandler.formatException(HIV_ApexSharing.class.getName(), 'Critical', ex, 'Error to add group member in Public group.');
            String sErrorInfoUpd = JSON.serialize(mapErrorInfo);
Thiruchuri AdityanThiruchuri Adityan

public class HIV_ContactTriggerHandler_Test{

static void insertCon(){
Contact con = new Contact();
con.LastName = 'test';
insert con;
try {
HIV_ContactTriggerHandler.onBeforeInsert(new List<contact>{con}, true, false);
}catch(Exception e){}



PS : The above code might give you coverage but the actual test class must be writeen from the trigger point of view as this seems like a trigger-handler.