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
Anshul BagdiyaAnshul Bagdiya 

How do I increase code coverage for the following apex class? Currently, its at 74%.

Public class AutoConvertLeads
    public static void LeadAssign(List<Id> LeadIds)
            Database.LeadConvert Leadconvert = new Database.LeadConvert();
            LeadStatus Leads= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true LIMIT 1];
            Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
Ruwantha  LankathilakaRuwantha Lankathilaka
Try following code it should give you 100% coverage 
@IsTest(SeeAllData = true)
public with sharing class ApexTest_AutoConvertLeads {

    static testMethod void testLeads(){

        Map<Id,Lead> idLeadMap = new Map<Id, Lead>([SELECT Id FROM Lead LIMIT 1000]);

        AutoConvertLeads.LeadAssign(new List<Id>(idLeadMap.keySet()));

If this helps you please mark it as the best answer so it could help the community in many ways.
Amit Chaudhary 8Amit Chaudhary 8
I will recommend you to start using trailhead to learn about test classes

Also please check below post

Please check below for sample test classes

Please try below test class
public with sharing class AutoConvertLeadsTest {

    static testMethod void testLeads(){

        Lead newLead = new Lead() ;
        newLead.FirstName = 'Cole';
        newLead.LastName = 'Swain';
        newLead.Company = 'BlueWave';
        newLead.Status = 'contacted';	
		insert newLead;
		List<Id> LeadIds = new List<Id>();

NOTE:- Try to avoid to use SeeAllData = true

Let us know if this will help you