global with sharing class Batchaccountcountfieldschedule implements Schedulable 
    global void execute(SchedulableContext sc)    
       Batchaccountcountfield bb = new Batchaccountcountfield();

1 Answer 1


In you test class schedule your class

Batchaccountcountfieldschedule sh1 = new Batchaccountcountfieldschedule();
String sch = '0 0 23 * * ?'; 
system.schedule('Test Territory Check', sch, sh1); 
// add system asserts to check your expected behaviour
  • @Bonny Cool It helped you
    – Ratan Paul
    Jan 21, 2016 at 5:47
  • 1
    Please don't take this the wrong way, but IMO this is not a test class. This is a 'coverage class'. All it gives you is code coverage to hit the 75% code coverage mark, but it does not test any behaviour. In order for this to be a good test, it needs to make some assertions about the code that's run. In this case, the test should ensure that the batch has run successfully.
    – mkorman
    Jan 21, 2016 at 9:33
  • Perhaps we should. If someone asks me how to do things the wrong way, I won't give him an answer. I rather explain how to do things the right way. You're not doing anybody a favour if you help them do things wrong. But that's a different discussion altogether :)
    – mkorman
    Jan 21, 2016 at 11:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .