You need to sign in to do that
Don't have an account?
SF Beginner 2019
I cannot covered the !obj.isSuccess()) is there an assertequals that might help? thank you
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
Anudeep (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?