How to test Scheduled Apex Jobs in Salesforce


Hi All,

We can test this by scheduling the apex class to run after 2 or few minutes, but salesforce UI allows scheduling apex on per hour basis. So, to overcome with this problem we can use below code which will schedule apex class as per the time we set. Please follow the steps below:

1. Open Developer console and click on debug option.

2. Click on Open Execute anonymous window.

3. Write below code to it:

String str =‘ss mm HH dd MM ? yyyy’);

System.schedule(‘Send Message’, str , new your_ClassName());

4. Click on Execute button.

And thats it. You have successfully scheduled the apex class to run in 2 minutes. You can change the time as you want.


About the author

By prashant.wayal