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
RohithaSfdcRohithaSfdc 

Need help for Test classes

Hi Friends, 
Thanks In advance , Please Help I am Struck over some point of below code,
I need Test coverage for this code please help.
if(leadList.Description!= null)
       {
         acc.Description = leadList.Description;
         if (leadList.Station_Formula__c == null && leadList.Station_from_Web_Form__c !=null )
           acc.Description += ' - ' + 'Station:' + leadList.Station_from_Web_Form__c;

         if (leadList.Station__c != null )
         {   
             System.debug('************** Drone Market' + leadList.Drone_Market__c);
             acc.Description += ' - ' + 'Station:' + leadList.Station_Formula__c;
             if (leadList.Operating_Market__c != null )
             acc.Description +=  ' , ' + 'Operating Market:' + leadList.Operating_Market_Formula__c;
             if (leadList.Drone_Market__c!= null )
             acc.Description +=  ' , ' + 'Drone Market:' + leadList.Drone_Formula__c;
         }
        update acc;
       }  
	   
	    if (leadList.Advertiser_or_Agency__c=='Advertising' && leadList.Agency_Relationship_lkup__c != null )
            System.Debug('**************************** Existing Primary Agency:' + leadList.ConvertedAccountId );
            Agency_Relationship__c agencyBudgetRelationship = new Agency_Relationship__c();
            Opportunity_Agency_Relationship__c oppAgencyRelationShip = new Opportunity_Agency_Relationship__c();
            agencyBudgetRelationship.Account__c = acc.Id;
            agencyBudgetRelationship.Agency_Account__c = leadList.Agency_Relationship_lkup__c ;
            agencyBudgetRelationship.Primary__c = true;
            agencyBudgetRelationship.Type__c='Buying Agency';
            opp.Agency_or_Direct__c = 'Agency';
            oppAgencyRelationShip.Opportunity__c = opp.Id;
            oppAgencyRelationShip.Type__c='Agency of Record';
            oppAgencyRelationShip.Agency_Account__c = leadList.Agency_Relationship_lkup__c ;
            oppAgencyRelationShip.Primary__c = true;
            opp.Type = 'Prospecting';
}
Thanks & Regards
Rohitha
 
AnuragGautamAnuragGautam
You have to create proper test data. Lead , then convert the lead and query the account. Then create test data for Agency_Relationship__c  , newOpportunity_Agency_Relationship__c once you are done with data creation. Then pelase call these methods.