+ Start a Discussion
rahul Shukla 37rahul Shukla 37 

Lead conversion forTest class

public class cfg_LeadUtility {
     @InvocableMethod(label='Convert the Lead' description='Convert the lead by LeadId and returns True/False as success/failures' category='Lead')
    public static List<String> ConvertLead(List<ID> leadIds) {
        List<String> convertedLeads= new List<String>();
        LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
        for (String leadId: leadIds) {
            Database.LeadConvert lc = new Database.LeadConvert();
            lc.setLeadId(leadId);
            lc.setConvertedStatus(convertStatus.MasterLabel);   
                    
            Database.LeadConvertResult lcr ;
            try{
                lcr = Database.convertLead(lc);
                system.debug('*****lcr.isSuccess()'+lcr.isSuccess());            
                convertedLeads.add(LeadId);
            }
            catch(exception ex){
                system.debug('***LEAD NOT CONVERTED**');           
            }
        }
        
        return convertedLeads;
    }   
}
i wants to test this class as per below Test class but not covering the code please anyone help me to find the issue in Test class
@isTest  
private class cfg_LeadUtilityTest {  
      
    static testMethod void testLeadConv() {  
          
        //Lead objLead = new Lead( FirstName = 'Test', LastName = 'Sample', Company = 'Testing Sample Co' );  
        Lead objLead = utilityHelperTest.createLead();
        insert objLead;  
          
        Database.LeadConvert lc = new database.LeadConvert();  
        lc.setLeadId( objLead.Id );  
        //lc.setDoNotCreateOpportunity( true );  
        lc.setConvertedStatus( 'Closed - Converted' );  
          
        Database.LeadConvertResult lcr = Database.convertLead(lc, false);  
          
        system.debug( 'Errors are ' + lcr.getErrors() );  
          
        system.assert( lcr.isSuccess() );  
          
    }  
  
}