function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nishit MistryyyNishit Mistryyy 

Write a test class scheulde

I have one class that is defined, I want to write a test class for it with an EXPLANATION!!
The code for the apex class is :

global class ScheduleToUpdateMilestoneTargetdate implements schedulable{
    global void execute(Schedulablecontext sc)
        BatchClassToUpdateCaseObject cases=new BatchClassToUpdateCaseObject();

Sai PraveenSai Praveen (Salesforce Developers) 
Hi Nitish,

Your class only gets 75% coverage because the below code cannot be covered.
Because this piece of code will not run in test class hence we loose the covearage for this

We are just initilizing thr schedular class and setting to schedule this at particualr time
public class TestAccount {
static testMethod void myUnitTest()  {
ScheduleToUpdateMilestoneTargetdate sh1 = new ScheduleToUpdateMilestoneTargetdate();

String sch = '0 0 23 * * ?';
    system.schedule('Test Territory Check', sch, sh1);


Let me know if you face any issues.

If this solution helps, Please mark it as best answer.