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
karthikarthi 

pls help me to cover the if else part in test class

my if else part is:

if (Acc.size() > 0)
        {
            for(GE_PW_User_Sales_Hierarchy_Association__c c : Acc) {
            system.debug('parent:'+c.GE_PW_Parent_Location_ID__c);

               if(Locationid.size()>0)
               {
                   for(GE_PW_User_sales_Hierarchy_Association__c l : Locationid)
                   {
                      if(l.GE_PW_Location_ID__c==c.GE_PW_Parent_Location_ID__c)
                       {   status='Valid';
                            break;
                               //intcount++;
                       }   
                       else  
                       {  
                       for(GE_PW_User_Sales_Hierarchy_Association__c a : Acc) {
                        if(c.GE_PW_Parent_Location_ID__c==a.GE_PW_Location_ID__c)
                         {
                         status='Valid';
                         break;
                         }
                        else
                         {          
                          status='Invalid';
                            //intcount++;
                         }
                        }
                       }
                    }
              }
         pls help me to write the test class to cover it      

bob_buzzardbob_buzzard

You'll need to construct data in order to exercise the various conditional paths.

 

It looks like you'll need to have an instance of GE_PW_User_Sales_Hierarchy_Association__c in the accs collection whose location doesn't match an instance of GE_PW_User_sales_Hierarchy_Association__c in the LocationId collection.