You need to sign in to do that
Don't have an account?

How do I increase code coverage for the following apex class? Currently, its at 74%.
Public class AutoConvertLeads
{
@InvocableMethod
public static void LeadAssign(List<Id> LeadIds)
{
Database.LeadConvert Leadconvert = new Database.LeadConvert();
Leadconvert.setLeadId(LeadIds[0]);
LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
Leadconvert.setConvertedStatus(Leads.MasterLabel);
Leadconvert.setDoNotCreateOpportunity(TRUE);
Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
System.assert(Leadconverts.isSuccess());
}
}
{
@InvocableMethod
public static void LeadAssign(List<Id> LeadIds)
{
Database.LeadConvert Leadconvert = new Database.LeadConvert();
Leadconvert.setLeadId(LeadIds[0]);
LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
Leadconvert.setConvertedStatus(Leads.MasterLabel);
Leadconvert.setDoNotCreateOpportunity(TRUE);
Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
System.assert(Leadconverts.isSuccess());
}
}
If this helps you please mark it as the best answer so it could help the community in many ways.
1) https://trailhead.salesforce.com/modules/apex_testing
Also please check below post
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_qs_test.htm
2) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_example.htm
Please check below for sample test classes
1) http://amitsalesforce.blogspot.com/2015/06/best-practice-for-test-classes-sample.html
Please try below test class
NOTE:- Try to avoid to use SeeAllData = true
Let us know if this will help you