You need to sign in to do that
Don't have an account?
GMASJ
Trigger is having 100% code coverage still not able to deploy
Hi,
I have a below simple trigger it has 100% code coverage
I keep getting below message when validated in production
Code Coverage Failure
The following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.
updateopportunitycontact
Please suggest me what might be the issue in the code.
Thanks
Sudhir
I have a below simple trigger it has 100% code coverage
trigger updateopportunitycontact on Lead (before update) { for(Lead lead:System.Trigger.new) { if (lead.IsConverted && lead.ConvertedOpportunityId != null ) { Contact con = [SELECT Id FROM Contact WHERE Contact.Id = :lead.ConvertedContactId]; Opportunity opp = [SELECT Contact__c from Opportunity where opportunity.id = :lead.ConvertedOpportunityId]; opp.Contact__c = lead.ConvertedContactId; update opp; } } }Test Class
@isTest(SeeAllData = true) private class test_updateopportunitycontact { public static testmethod void testupdateoppcon() { test.startTest(); Lead testLead = new Lead( LastName='123456789890654', Company = 'Couchbase11', LeadSource = 'Training', run_assn_rules_yn__c = False ); insert testLead; Database.LeadConvert lc = new database.LeadConvert(); lc.setLeadId(testLead.id); LeadStatus convertStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1]; lc.setConvertedStatus(convertStatus.MasterLabel); Database.LeadConvertResult lcr = Database.convertLead(lc); System.assert(lcr.isSuccess()); test.stopTest(); } }
I keep getting below message when validated in production
Code Coverage Failure
The following triggers have 0% code coverage. Each trigger must have at least 1% code coverage.
updateopportunitycontact
Please suggest me what might be the issue in the code.
Thanks
Sudhir
Thanks
Make your Test Class as Public and try again.
Hope this will help you. Let me know if it helped or you need any more assistance.
Please mark this is as the solution if it solved your purpose.
Thanks,
Sohan Raj Gupta
I tried your suggestion it is still same not sure what the issue here
Thanks
Make sure on production have below custom fields:-
IsConverted
ConvertedOpportunityId
Contact__c
ConvertedContactId
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh