+ Start a Discussion
BMC GroupBMC Group 

Code Coverage of method of method in a class

 

Below is my Code. Please assist me why code in red color is not covering. We have a manage pacakge to send SMS to a mobile number.  

 

The Class

public void sendSMSToSir(List<Operation__c> OperationList){
 46	          for(Operation__c srnData&colon; operationList){
 47	              if((recordTypeMap.get(srnData.RecordTypeid) == 'LLP')
 48	                 ||(recordTypeMap.get(srnData.RecordTypeid) == 'Public')
 49	                 ||(recordTypeMap.get(srnData.RecordTypeid) == 'Private')) {
 50	                  if(recordTypeMap.get(srnData.RecordTypeid) == 'LLP'){
 51	                      CompanyExtention ='LLP';
 52	                  }else if (recordTypeMap.get(srnData.RecordTypeid) == 'Public'){
 53	                      CompanyExtention ='Ltd.';       
 54	                  }else if(recordTypeMap.get(srnData.RecordTypeid) == 'Private') {
 55	                      CompanyExtention ='Pvt. Ltd.';
 56	                  }
 57	                  
 58	                  System.Debug('--- current status---'+ srnData.Current_Status__c);
 59	                  if(srnData.Current_Status__c == 'Name Appln Filed'){
 60	                      if(srnData.Service_Segment__c == 'LLP Registration'){
 61	                          System.Debug('--- SRN Details of LLP Form 1 and its msg---');
 62	                          msg ='ROC Name- '+srnData.ROC_1st_Name__c+'\r\nForm 1\r\nSRN No.- '+srnData.Form_1A_1_SRN__c+'\r\n'+srnData.Company_Name_First_Option__c+' '+ CompanyExtention+'\r\nFiling Date- '+srnData.Form_1A_1_Date__c;
 63	                          sendSMS(sirMobile,msg);
 64	                      }else if(srnData.Service_Segment__c=='Company Registration'){
 65	                          System.Debug('--- SRN Details of Form 1A Comp Registration and its msg---');
 66	                          msg ='ROC Name- '+srnData.ROC_1st_Name__c+'\r\nForm 1A \r\nSRN No.- '+srnData.Form_1A_1_SRN__c+'\r\n'+srnData.Company_Name_First_Option__c+' '+CompanyExtention+'\r\nFiling Date- '+srnData.Form_1A_1_Date__c;
 67	                          sendSMS(sirMobile,msg);
 68	                      }

 test class is entering in if and else if but not reaching to 'msg' variable and sendSMS(sirMobile, msg) of the above code

 

 Here is the trigger from where the above code is calling

 

  for(Operation__c tempOpp : trigger.new){
        System.debug('New company Name( Tin)--'+trigger.isInsert+'--(tiA)--'+trigger.isAfter+'-(tiB)--'+trigger.isBefore+'-(tiU)--'+ trigger.isUpdate+'---'+ tempOpp.New_Company_name__c+'---'+tempOpp.Form_1A_1_SRN__c+'---'+ tempOpp.Incorporation_SRN__c );
            
            if(tempOpp.Current_Status__c == 'Name Appln Filed'
                || tempOpp.Current_Status__c =='Name Resubmission'
                || tempOpp.Current_Status__c== 'Incorporation Filed'
                || tempOpp.Current_Status__c =='Incorporation Resubmission'){       
                If((trigger.isBefore
                    || trigger.isUpdate
                    || trigger.isAfter)
                    && ( trigger.oldMap.get(tempOpp.id).current_status__c != trigger.newMap.get(tempOpp.id).current_status__c)){
                    System.debug('--Current Status---'+ trigger.oldMap.get(tempOpp.id).current_status__c +'!='+ trigger.newMap.get(tempOpp.id).current_status__c) ;    
                    SRNDetails SRN = new SRNDetails(); 
                    SRN.newRecordsOfSRN(trigger.new); 
                    SRN.sendSMSToSir(trigger.new);
                }
            }
        } 

 Here is my test class

 

tempOperation.get(0).current_status__c = ' Name Appln Filed';
                tempOperation.get(0).Company_Name_First_Option__c= 'First Option';
                tempOperation.get(0).Form_1A_1_SRN__c = 'V564789321';
                tempOperation.get(0).Form_1A_1_Date__c = date.parse('04/07/2013');
                tempOperation.get(0).ROC_Name__c='Andhra Pradesh -- Andhra Pradesh';
                update tempOperation;
                
                SRNDetails SRNRecords = new SRNDetails();
                SRNRecords.newRecordsOfSRN(tempOperation);
                SRNRecords.sendSMSToSir(tempOperation);
                
                tempOperation.get(0).current_status__c = ' Name Resubmission';
                tempOperation.get(0).Company_Name_First_Option__c= 'Second Option';
                tempOperation.get(0).Form_1A_1_SRN__c = 'V564789321';
                tempOperation.get(0).Form_1A_1_Date__c = date.parse('04/07/2013');
                tempOperation.get(0).ROC_Name__c='Andhra Pradesh -- Andhra Pradesh';
                update tempOperation;
                System.Debug('---List contain UT2(1)---'+ tempOperation);
                SRNDetails SRNRecords1 = new SRNDetails();
                SRNRecords1.newRecordsOfSRN(tempOperation);
                SRNRecords1.sendSMSToSir(tempOperation);

 Please help me and thanks in anticipation.

 

Regards

 

Rohit

zokitozokito

Hi,

 

i can't see where you have defined the msg variable? 

 

The first time you use it is at line 62 where you just assign the value to it, the variable should be declared somewhere first.

 

br,

 

zoran