You need to sign in to do that
Don't have an account?
Newbie999
can someone please tell me why I am not getting 100% code coverage?
below is my code
@isTest private class DailyLeadProcessorTest { public static string t='0 0 12 7 17 ?'; static testmethod void testscheduleLead(){ /*List<Lead> leads = new List<Lead>(); for(Integer i = 0; i < 200; i++){ Lead lead = new Lead(LastName = 'Test ' + i, LeadSource = '', Company = 'Test Company ' + i, Status = 'Open - Not Contacted'); leads.add(lead); } insert leads;*/ list<lead> newleads= new list<lead>(); for(integer i=0;i<200;i++){ lead l= new lead(LastName='test lastName'+i,company='test company'); newleads.add(l); } insert newleads; test.startTest(); Integer n=[select count() from Lead where LastName like '%test%']; system.assertEquals(200,n,'200 new leads not created'); integer c=[select count() from lead where leadSource='Dreamforce']; system.assertEquals(0,c, 'dreamforce leads found'); //DailyLeadProcessor d= new DailyLeadProcessor(); string jobId= system.schedule('scheduleleadprocessor',t,new DailyLeadProcessor()); test.stopTest(); }}
global class DailyLeadProcessor implements schedulable { global void execute(SchedulableContext ctx){ list<lead> list1=[select id, name, leadSource from lead where leadSource=null]; if (!list1.isEmpty()){ for(lead l: list1){ l.leadSource='Dreamforce'; } update list1;} } }
- I read your problem and implemented it in my Org and it is working fine.
- Please use the below code (Solved with 100% code coverage)
-------------- Schedule Class------- -----
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha.
All Answers
- I read your problem and implemented it in my Org and it is working fine.
- Please use the below code (Solved with 100% code coverage)
-------------- Schedule Class------- -----
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha.