You need to sign in to do that
Don't have an account?
SFAdmin5
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(); database.executebatch(x); } 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
}
@isTest
global static void testSchedule()
{
Test.startTest();
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
Test.stopTest();
}
}
Hi
See this link hope this will helps u.
http://boards.developerforce.com/t5/Apex-Code-Development/testMethod-help-for-class-that-implements-Schedulable/td-p/154214
Regards,
Rajesh S