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
SF Beginner 2019SF Beginner 2019 

test class for exception log

public static boolean insertExceptionRecs(List<Database.SaveResult> srList){
        try{
            List<ExceptionLog__c> excpLst = New List<ExceptionLog__c>();
            boolean isError = False;
            ExceptionLog__c objLog= new ExceptionLog__c();
            if(!srList.isEmpty()){
                for(Database.SaveResult obj : srList){
                    for(Database.Error objErr : obj.getErrors()){
                        if(!obj.isSuccess()){
                            objLog = new ExceptionLog__c(
                                Object_ID__c =obj.getId(),
                                ExceptionDescription__c = objErr.getMessage(),
                                ExceptionCode__c =  EXCPCODE,
                                NumberOfTimesOccured__c = OCCURENCE + 1,
                                ExceptionDetails__c = objErr.getMessage(),
                                Severity__c = EXCPSVRTY);
                            excpLst.add(objLog);
                        } 
                    }
                }
            }
            if(!excpLst.isEmpty()){
                Database.upsert(excpLst,false);
                isError = true;
            }
            return isError;
        }
        Catch(Exception e)
        {
            GA_LogExceptionCls.LogExcp(e, CLSNAME,METHODINSERTXCPTNRECDS);
           return false;
        } 
    }

I cannot covered the !obj.isSuccess()) is there an assertequals that might help? thank you
AnudeepAnudeep (Salesforce Developers) 
I am suspecting either the srList must be null or obj.getErrors() must be null. Can you try adding a system debug to confirm that?