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
Aaron Persich 15Aaron Persich 15 

Inbound Change set Code Coverage failure

Hello,

I am trying to push an Apex Class which auto converts a lead into a contact.  When I try to deploy this in production I get the following error.  I am not too familiar with Apex Classes and not sure how to resolve this.

Your code coverage is 38%. You need at least 75% coverage to complete this deployment.
 
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); //Remove this line if you want to   create an opportunity from Lead Conversion 
            Database.LeadConvertResult Leadconverts = Database.convertLead(Leadconvert);
            System.assert(Leadconverts.isSuccess());
   }
}


Any help is much appreciated.

Thanks,

Aaron
 
PabitraPabitra
Dear Aaron,
Can you please share your test class code?

Many Thanks!
Jerry BlackwoodJerry Blackwood
Apex legends class?))
subodhsubodh
Hi Aaron,

The test class needs to have atleat 75% code coverage. Can you share the test class.
Thanks