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 

test class for milestone date

I have a class and I want to write a test class for it, The code of the class is as follows:

public class MilestoneUtils {

    public static void completeMilestone(List<Id> caseIds, DateTime complDate) {  
    List<CaseMilestone> cmsToUpdate = [select Id, completionDate
            from CaseMilestone cm
            where caseId in :caseIds 
            and completionDate = null limit 1];
    if (cmsToUpdate.isEmpty() == false){
        for (CaseMilestone cm : cmsToUpdate){
            cm.completionDate = complDate;
            }
        update cmsToUpdate;
        }
    }

SwethaSwetha (Salesforce Developers) 
HI Nishit,
Please highlight which lines of code are uncovered. The below articles give a good insight into how coverage can be improved
 
https://salesforce.stackexchange.com/questions/244794/how-do-i-increase-my-code-coverage-or-why-cant-i-cover-these-lines 
 
Examples of Milestone completion test classes:
https://salesforce.stackexchange.com/questions/150226/milestone-completion-test-class-not-getting-100-code-coverage
 
https://salesforce.stackexchange.com/questions/141607/57-code-coverage-on-milestone-complete
 
https://salesforce.stackexchange.com/questions/275562/i-am-writing-a-test-class-on-case-object-with-entitlement-and-im-receiving-an

If this information helps, please mark the answer as best. Thank you