You need to sign in to do that
Don't have an account?
AntonPavlov
here apex code
global with sharing class schedularCloseAllDealsMonthAgo implements Schedulable{
global void execute(SchedulableContext sc) {
closeAllDealsMonthAgo closeDeals = new closeAllDealsMonthAgo();
database.executebatch(closeDeals);
}
public static void schedulerMethod(){
schedularCloseAllDealsMonthAgo sched = new schedularCloseAllDealsMonthAgo();
string con_exp= '0 0 10 * * ?';
System.schedule('schedularCloseAllDealsMonthAgo', con_exp, sched);
}
}
This is code of test but not work for 100%
@isTest
public class schedularCloseAllDealsMonthAgoTest {
public static testMethod void testschedule() {
Test.StartTest();
schedularCloseAllDealsMonthAgo sched = new schedularCloseAllDealsMonthAgo();
String CRON_EXP = '0 0 23 * * ?';
System.schedule('schedularCloseAllDealsMonthAgo', CRON_EXP, sched);
Test.stopTest();
}
}
help to solve, write test apex schedular
here apex code
global with sharing class schedularCloseAllDealsMonthAgo implements Schedulable{
global void execute(SchedulableContext sc) {
closeAllDealsMonthAgo closeDeals = new closeAllDealsMonthAgo();
database.executebatch(closeDeals);
}
public static void schedulerMethod(){
schedularCloseAllDealsMonthAgo sched = new schedularCloseAllDealsMonthAgo();
string con_exp= '0 0 10 * * ?';
System.schedule('schedularCloseAllDealsMonthAgo', con_exp, sched);
}
}
This is code of test but not work for 100%
@isTest
public class schedularCloseAllDealsMonthAgoTest {
public static testMethod void testschedule() {
Test.StartTest();
schedularCloseAllDealsMonthAgo sched = new schedularCloseAllDealsMonthAgo();
String CRON_EXP = '0 0 23 * * ?';
System.schedule('schedularCloseAllDealsMonthAgo', CRON_EXP, sched);
Test.stopTest();
}
}
Hi Anton,
Change your test class as below:
@isTest
public class schedularCloseAllDealsMonthAgoTest {
public static testMethod void testschedule() {
Test.StartTest();
schedularCloseAllDealsMonthAgo.schedulerMethod();
Test.stopTest();
}
}
Hope this helps
Thanks,
Sucharita
All Answers
>> http://amitsalesforce.blogspot.com/2017/07/how-to-write-test-class-for-scheduler.html
In the above link, there is an example of a schedulable class, and below is the sample test class that you can use to implement your test class.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Hi Anton,
Change your test class as below:
@isTest
public class schedularCloseAllDealsMonthAgoTest {
public static testMethod void testschedule() {
Test.StartTest();
schedularCloseAllDealsMonthAgo.schedulerMethod();
Test.stopTest();
}
}
Hope this helps
Thanks,
Sucharita