+ Start a Discussion
Derrick CalderonDerrick Calderon 

Apex Deployment Error

The code works fine in Dev Environment, but it wont deploy to production.

Here is the error:
LeadConvert; null, Details: Test coverage of selected Apex Trigger is 0%, at least 1% test coverage is required; Average test coverage across all Apex Classes and Triggers is 0%, at least 75% test coverage is required.

Here is the code:
 
trigger LeadConvert on Lead (after insert,after update) {
//Bulkified
	List<String> LeadNames = new List<String>{};
	for(Lead myLead: Trigger.new){
 		if((myLead.isconverted==false) && (myLead.Ready_to_Convert__c == True)){
			Database.LeadConvert lc = new database.LeadConvert();
            lc.setLeadId(myLead.Id);
            lc.convertedStatus = 'Qualified';
            //Database.ConvertLead(lc,true);
            lc.setDoNotCreateOpportunity(false);
            Database.LeadConvertResult lcr = Database.convertLead(lc);
            System.assert(lcr.isSuccess());
		}
	}
}

Can you assist?

Thank you

Derrick
Marek Kosar_Marek Kosar_
Hi Derrick,

have you created test method for this trigger?
From what you posted, it looks like you don't, but you need it for deployment.

Something like (it's just a sample:)):
@isTest
private class LeadTestClass{
  static testMethod void afterInsertLeadTest(){		

    Lead testLead = new Lead (Ready_to_Convert__C = true, /*....other required fields for lead creation*/);
    insert testLead;  // this will fire your Lead trigger

  }
}