• Andrew Lewis 20
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I am trying to create a class that does nothing more than fire a set of Apex Scheduler classes I have created. Here is the test class I have created to execute them.
 
@isTest(seeAllData=true)
private class TestCronClass {
	
	@isTest static void executeCrons() {
		
		String sch = '0 0 23 * * ?';

		Test.StartTest();
			
			ClientDetlaCron clientCron = new ClientDetlaCron();
			System.schedule('Test Client Cron', sch, clientCron);
			
			PolicyCronBatchQuery policyCron = new PolicyCronBatchQuery(); 
			System.schedule('Test Policy Cron', sch, policyCron);
		

		Test.stopTest();
	

	}
	
	
}

I am getting an error becuase in the Scheduler classes they do nothing more than fire off a Callout to an external system. The test class fails since the class is executing a callout class.

I was thinking about using "if (Test.isRunningTest())" and try and avoid this but wanted to see if anyone has any better design patterns here. 

One of my scheduler classes. The other one is the exact same just calls a different callout.
global class ClientDetlaCron implements Schedulable {
	
	global void execute(SchedulableContext sc) {
		// Fire Soap Request to Sagitta for Changes in Policy Data
		ClientBatchQuery.sendBatchQuery();		
	}
}


I already have a Test Class and MockClass for the Callouts. 

Thanks for you help.