You need to sign in to do that
Don't have an account?

need test class
Hi:
Can anyone provide a test class for this trigger that might work? Thanks!
trigger UpdateCustomServicesBillingInvoiceObject_Trigger on Lead (after update) { Map<Id, Lead> leadMap = new Map<Id,Lead>(); Lead parent; for (Integer i = 0; i < Trigger.new.size(); i++){ if (Trigger.new[i].IsConverted == true && Trigger.old[i].isConverted == false) { leadMap.put( Trigger.new[i].Id, Trigger.new[i]); } } if( leadMap.size() > 0 ) { Set<Id> leadIds = leadMap.keySet(); List<Custom_Services_Billing_Invoice__c> allChildren = [select Id, Account__c, Lead__c from Custom_Services_Billing_Invoice__c where lead__c in :leadIds]; System.debug(allChildren); for ( Custom_Services_Billing_Invoice__c child : allChildren ) { if ( leadMap.containsKey( child.Lead__c ) ) { parent = leadMap.get( child.Lead__c ); child.account__c = parent.ConvertedAccountId; } } System.debug(allChildren); update allChildren; } }
@isTest
private class TM_clsTestLead {
static testMethod void myUnitTest() {
// TO DO: implement unit test
Lead objLead = new Lead();
objLead.FirstName = 'Test123';
objLead.LastName = 'Test234';
objLead.Company = 'Test ltd233';
objLead.Status = 'Open';
objLead.Phone = '011-2345678';
objLead.LeadSource = 'Email';
objLead.City = 'Test City';
objLead.Street = 'Test Lead Street'; i
nsert objLead;
//Convert the Lead
Database.LeadConvert lc = new database.LeadConvert();
lc.setLeadId(objLead.Id);
//Create record in your Custom Object Custom_Services_Billing_Invoice__c
}
}
Let me know if need any help...
Thanks
Anand Singh
Thanks Anand. Looks like the trigger is passing 38% coverage with your test class. Any idea how we can get it up to at least 75, ideally 90? Thanks again!