You need to sign in to do that
Don't have an account?
v varaprasad
test class for schedule apex
Hi All ,
i am writing test class for following schedule class
global class scheduleAccountWriteXML implements Schedulable{
// Execute method
global void execute(SchedulableContext SC) {
try{
// Code to be executed when the schedule class wakes up
CalloutAccountRequest.basicAuthCalloutRequest();
String CRON_EXP = '0 0 * * * ?';
string jobName = 'Account_Interface_Schedule_job_that_runs_every_1_hour_for_Accounts';
scheduleAccountWriteXML p = new scheduleAccountWriteXML();
system.schedule(jobName, CRON_EXP, p);
}
Catch (Exception e){
Messaging.SingleEmailMessage emailMessage = new Messaging.SingleEmailMessage();
emailMessage.setToAddresses(new String[] { 'varaprasad.vemula@accenture.com'});
emailMessage.setSubject('Subject');
emailMessage.setPlainTextBody(e.getmessage());
Messaging.SendEmailResult[] emailResult = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { emailMessage}, true);
}
}
}
I received code 90%,but test execution will be fail .
@isTest
public class Test_scheduleAccountWriteXML {
public static testmethod void testaccountxml(){
Test.StartTest();
String CRON_EXP = '0 0 * * * ?';
scheduleAccountWriteXML scc6= new scheduleAccountWriteXML();
String jobid = system.schedule('varam', CRON_EXP, scc6);
Test.StopTest();
}
}
Any help please.
i am writing test class for following schedule class
global class scheduleAccountWriteXML implements Schedulable{
// Execute method
global void execute(SchedulableContext SC) {
try{
// Code to be executed when the schedule class wakes up
CalloutAccountRequest.basicAuthCalloutRequest();
String CRON_EXP = '0 0 * * * ?';
string jobName = 'Account_Interface_Schedule_job_that_runs_every_1_hour_for_Accounts';
scheduleAccountWriteXML p = new scheduleAccountWriteXML();
system.schedule(jobName, CRON_EXP, p);
}
Catch (Exception e){
Messaging.SingleEmailMessage emailMessage = new Messaging.SingleEmailMessage();
emailMessage.setToAddresses(new String[] { 'varaprasad.vemula@accenture.com'});
emailMessage.setSubject('Subject');
emailMessage.setPlainTextBody(e.getmessage());
Messaging.SendEmailResult[] emailResult = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { emailMessage}, true);
}
}
}
I received code 90%,but test execution will be fail .
@isTest
public class Test_scheduleAccountWriteXML {
public static testmethod void testaccountxml(){
Test.StartTest();
String CRON_EXP = '0 0 * * * ?';
scheduleAccountWriteXML scc6= new scheduleAccountWriteXML();
String jobid = system.schedule('varam', CRON_EXP, scc6);
Test.StopTest();
}
}
Any help please.
[1] http://blog.deadlypenguin.com/blog/2012/05/26/scheduled-actions-in-salesforce-with-apex/