You need to sign in to do that
Don't have an account?
Marina Kostopoulou
Improve Apex Class with test with code coverage 44% to 75%
I don't have previous experience with Apex Code. I created an apex class that converts the Lead to Account and I write a simple test. With the current status my code coverage is 44% and I need at least 75% in order to deploy it in production. Can someone help me write that ?
Apex Class
Apex Class
Public class AutoConvertLeads { @InvocableMethod public static void LeadAssign(List<Id> LeadIds) { List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>(); for(id currentlead: LeadIds){ Database.LeadConvert Leadconvert = new Database.LeadConvert(); Leadconvert.setLeadId(currentlead); Leadconvert.setConvertedStatus('Qualified'); MassLeadconvert.add(Leadconvert); } if (!MassLeadconvert.isEmpty()) { List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert); } } }Test Class
@isTest private class AutoConvertLeads_Test{ static testMethod void test_LeadAssign_UseCase1(){ AutoConvertLeads obj01 = new AutoConvertLeads(); AutoConvertLeads.LeadAssign(new List<Id>()); } }
Please check below code snippet might help
Thanks
Pranav
Chnage this to
AutoConvertLeads.LeadAssign(lstOfLeadIds); --> AutoConvertLeads.LeadAssign(lstOfLeadIds.Id);
That was just a skeleton , u need to geet the converted lead as well