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

Unable to cover page reference part in my test class.

How to write a test class for this page reference method.i am unable to cover this part on my controllerclass.

public pagereference saveRecord()
        List<Min_Tier_threshold__c> discLocal=accon.clone() ;
        List<Min_Tier_threshold__c> discLocal2=new List<Min_Tier_threshold__c>(accon);
         integer i=0;
        for(Min_Tier_threshold__c Tier:accon){
               if(Tier.SMS_Threshold__c==null && Tier.SMS_Tier__c ==null && Tier.SMS_Tier_Description__c==null )
               { discLocal2.remove(i); }
               else if(Tier.SMS_Threshold__c==null || Tier.SMS_Tier__c ==null || Tier.SMS_Tier_Description__c==null )
               ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,'You must enter all required fields');
               return null;
          upsert discLocal2; 
        PageReference pageRef = new PageReference('/apex/ExhibitAadminTier?retURL=/apex/ExhibitAAdmin');
        return pageref; 
     public PageReference cancel()  
      PageReference pg1=new PageReference('/apex/ExhibitAadminTier?retURL=/apex/ExhibitAAdmin');
      return pg1;
   public void addrow() {
        Min_Tier_threshold__c proTier = new Min_Tier_threshold__c();
        proTier .SMS_Threshold__c= (agnt.SMS_Threshold__c);
        proTier .SMS_Tier__c =(agnt.SMS_Tier__c );
        proTier .SMS_Tier_Description__c=(agnt.SMS_Tier_Description__c);
        accon.add(proTier );

this is my test class---
PageReference pageRef = Page.ExhibitAadminTier; // Adding VF page Name here
        pageRef.getParameters().put('id', String.valueOf(;//for page reference
        ApexPages.StandardController sc = new ApexPages.standardController(min1);
        ExhibitAadminTier controller = new ExhibitAadminTier(sc);
James LoghryJames Loghry
Which part is not being covered?  It looks like you're calling the three public methods above, so at least part of those methods should be covered.  Also, could you post the entire test method, and use the code formatting tool < > when doing so?  Thanks.