• Moloy Biswas 17
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
Trigger is as below:
trigger CMbeforeUpdate on CM__c (before Update) {
    List<CM__c> listCMUpdate = new List<CM__c>();
    for(CM__c cm : trigger.new) {
        if(cm.CM_Reason__c != trigger.oldMap.get(cm.id).CM__c 
            || cm.Location__c != trigger.oldMap.get(cm.id).Location__c
            
            || cm.Credit_LOB__c != trigger.oldMap.get(cm.id).Credit_LOB__c) {
            listCMUpdate.add(cm);
        }
    }
    if( listCMUpdate.size() > 0)
    { 
        CM_Handler.updateReasonCategoryCode(listCMUpdate);
        CM_Handler.CMapproverdetails(listCMUpdate);
    }    
}
The test class is:
@isTest
public class CMbeforeUpdatetest {
static testMethod void testCheck() {
   CM__c cm= new CM__c();
    cm.name = 'test';
    cm.CM_Reason__c = 'test';
    cm.Location__c = 'test';
 
  
    insert cm; 
    
    cm.Location__c = 'test123';
    
    update cm;
   
  }
}
the coverage is 70%. Need to cover " listCMUpdate.add(cm);" part, How to do that?
trying to write the test class for below trigger:

trigger CMbeforeUpdate on CM__c (before Update) {
    List<CM__c> listCMUpdate = new List<CM__c>();
    for(CM__c cm : trigger.new) {
        if(cm.CM_Reason__c != trigger.oldMap.get(cm.id).CM__c 
            || cm.Location__c != trigger.oldMap.get(cm.id).Location__c
            
            || cm.Credit_LOB__c != trigger.oldMap.get(cm.id).Credit_LOB__c) {
            listCMUpdate.add(cm);
        }
    }
    if( listCMUpdate.size() > 0)
    { 
        CM_Handler.updateReasonCategoryCode(listCMUpdate);
        CM_Handler.CMapproverdetails(listCMUpdate);
    }    
}

but unable to cover testcoverage. Need help!
Trigger is as below:
trigger CMbeforeUpdate on CM__c (before Update) {
    List<CM__c> listCMUpdate = new List<CM__c>();
    for(CM__c cm : trigger.new) {
        if(cm.CM_Reason__c != trigger.oldMap.get(cm.id).CM__c 
            || cm.Location__c != trigger.oldMap.get(cm.id).Location__c
            
            || cm.Credit_LOB__c != trigger.oldMap.get(cm.id).Credit_LOB__c) {
            listCMUpdate.add(cm);
        }
    }
    if( listCMUpdate.size() > 0)
    { 
        CM_Handler.updateReasonCategoryCode(listCMUpdate);
        CM_Handler.CMapproverdetails(listCMUpdate);
    }    
}
The test class is:
@isTest
public class CMbeforeUpdatetest {
static testMethod void testCheck() {
   CM__c cm= new CM__c();
    cm.name = 'test';
    cm.CM_Reason__c = 'test';
    cm.Location__c = 'test';
 
  
    insert cm; 
    
    cm.Location__c = 'test123';
    
    update cm;
   
  }
}
the coverage is 70%. Need to cover " listCMUpdate.add(cm);" part, How to do that?
trying to write the test class for below trigger:

trigger CMbeforeUpdate on CM__c (before Update) {
    List<CM__c> listCMUpdate = new List<CM__c>();
    for(CM__c cm : trigger.new) {
        if(cm.CM_Reason__c != trigger.oldMap.get(cm.id).CM__c 
            || cm.Location__c != trigger.oldMap.get(cm.id).Location__c
            
            || cm.Credit_LOB__c != trigger.oldMap.get(cm.id).Credit_LOB__c) {
            listCMUpdate.add(cm);
        }
    }
    if( listCMUpdate.size() > 0)
    { 
        CM_Handler.updateReasonCategoryCode(listCMUpdate);
        CM_Handler.CMapproverdetails(listCMUpdate);
    }    
}

but unable to cover testcoverage. Need help!