+ Start a Discussion
sfdc18sfdc18 

test code coverage for if-else loop

Hi,

I have written a below trigger and its test class.
For test class I am getting 34% code coverage.
How to write test class for this to get complete code coverage.
trigger UpdateRecTrigger on Account (before update) {

    for (Account a : Trigger.new) {
        
        RecordType rt = [SELECT Id, Name FROM RecordType WHERE SobjectType='Account' AND Name ='Rec1'];
        if (Trigger.isBefore) {
        if(a.RecordTypeId == rt.Id && c.Number__c != null){
            
            Id aId = a.Id;
            a.Count__c += 1;

            if(a.Count__c > 1){

                if(!a.Flag__c){
                    
                    if(!System.isFuture()){
                    AccountClass.updateRec(aId);
                    } else {
                    AccountClass.updateRecName(aId);
                    }

                } else {
                  
                   a.Flag__c = false;
                }

            }
       
        }
      }
    }

}


 
Michael VerhovskiMichael Verhovski
Where is your test class?