+ 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) {
	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.convertedStatus = 'Qualified';
            Database.LeadConvertResult lcr = Database.convertLead(lc);

Can you assist?

Thank you

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:)):
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