• radd clif
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hello, My test class is only covering 70% of my class. How can I get it to cover 100%?

Here is the Class:
public class CBOHandler {
    public static void onAfterUpdate(List<CBO__c> CBOList, Map<Id, CBO__c> oldCBOMap) {

        for (CBO__c cbo : CBOList){
            if(oldCBOMap.get(cbo.Id).Pending_for_5_min__c == false && cbo.pending_for_5_min__c == true){
                         Set<string> cboSet = new Set<string>();
                            cboSet.add(cbo.id);
                            List<Discharge__c> disList = [select id,Referrals_Status__c from discharge__c where id in (select discharge_name__c from cbo__c where id in :cboset )];
                for (Discharge__c dis : disList){
                    if (dis.Referrals_Status__c != 'Pending Outcome'){
                        dis.Referrals_Status__c = 'Pending Outcome';
                    }
                     update disList;
                }
               
            }
            
        }
            
        
}
}


This portion is not being covered by the test:
                    if (dis.Referrals_Status__c != 'Pending Outcome'){
                        dis.Referrals_Status__c = 'Pending Outcome';
                    }
                     update disList;
                }



Here is the Test:
@isTest
public class CBOHandlerTest {
@isTest
    Static Void CboHandlerTestMethod(){
            Discharge__c d = new Discharge__c();
            d.Name = 'Test';
            d.Referrals_Status__c='Documents Uploaded';
                insert d;
        
        Cbo__c c = new Cbo__c();
        c.Pending_for_5_min__c = false;
        insert c;
        
         c = [SELECT Id, name FROM CBO__c WHERE Id =:c.Id];
        c.Pending_for_5_min__c = true;
        update c;
        system.debug(d.Referrals_Status__c);
 

  }
}