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
Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan 

How to write test class to cover the date fucntion tostartofweek()?

Hi,

 

Am in need of test class coverage for the date function. Am getting struggled at the point of tostartofweek() function. Now am getting 66% code coverage only.

 

Am copying my class here. Please find help me to cover this more than 75%.

 

Public class BusinessDay{
    public date getStartWeekData(date thisdate ){
            date startDate = thisdate.toStartofWeek();
            startDate = startDate+ 1;
            return startDate;
    }

    public string getMonthStart(date thisdate ){
       String month;
            Integer dt =  thisdate.day();
            Integer dtMonth = thisdate.month();            
            if(dtMonth == 1){
              month = 'Jan'+' '+ string.ValueOf(dt);
            }
            if(dtMonth == 2){
              month = 'Feb'+' '+ string.ValueOf(dt);
            }
            if(dtMonth == 3){
              month = 'Mar'+' '+ string.ValueOf(dt);
            }
            if(dtMonth == 4){
              month = 'Apr'+' '+ string.ValueOf(dt);
            }
            if(dtMonth == 5){
              month = 'May'+' '+ string.ValueOf(dt);
            }
            if(dtMonth == 6){
              month = 'Jun'+' '+ string.ValueOf(dt);
            }
            if(dtMonth == 7){
              month = 'Jul'+' '+ string.ValueOf(dt);
            }
            if(dtMonth == 8){
              month = 'Aug'+' '+ string.ValueOf(dt);
            }
            if(dtMonth == 9){
              month = 'Sep'+' '+ string.ValueOf(dt);
            }
       ........ and so on.
        return month;
    }
    }

 

 

Thanks in advance.