function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

need test class

can someone help me with a test class for the class below (scheduled apex job that works fine in testing...i just need test coverage for it)


global class deleteAccounts implements  Database.Batchable<sObject>, Schedulable {
String query = 'SELECT id from Account WHERE Name=test';
global deleteAccounts ()
  global void execute(SchedulableContext SC) {
      deleteAccounts x = new deleteAccounts(); 
global Database.QueryLocator start(Database.BatchableContext BC){
   return Database.getQueryLocator([SELECT id FROM Account WHERE Name ='test']);
global void execute(Database.BatchableContext BC, List<sObject> scope){
  delete scope;
global void finish(Database.BatchableContext BC){




I got the class and test class here. You can try similar to below test class.


global class MyScheduledProcess implements Schedulable
    global void execute(SchedulableContext ctx)
        // TODO: your code here

    global static void testSchedule()
        MyScheduledProcess sched = new MyScheduledProcess();
        Id job_id = System.schedule('test', '0 0 0 30 12 ? 2099', sched);
        System.assertNotEquals(null, job_id);
        // TODO: test your code