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
Michele ToscanoMichele Toscano 

Test Code Coverage for listAcc

if(listacc != null && !listacc.isEmpty())  - if this never evaluates to true- then how can I increase my code coverage of the block of code which follows- in order to increase my test class code coverage?  
Account acc = listacc[0];
            samObj.Planning_Account__c= acc.ParentId;
            samObj.Customer_Group__c= acc.Customer_Group_Description__c;
            samObj.CABOT_Segment__c= acc.CABOT_Segment__c;
            samObj.Account_Manager__c= acc.OwnerId;
            samObj.Technical_Manager__c= acc.Technical_Service_Manager__c;
            samObj.Ship_To_Address_Line_1__c= acc.Address_Line_1__c;
            samObj.Ship_To_Address_Line_2__c= acc.Address_Line_2__c;
            samObj.Ship_To_Address_Line_3__c= acc.Address_Line_3__c;
            samObj.Ship_To_Address_Line_4__c= acc.Address_Line_4__c;
            samObj.Account_Region__c= acc.Sub_Region__c;
            samObj.Ship_To_Country__c= acc.Country__c;
            samObj.Ship_To_State__c= acc.State__c;
            samObj.Ship_To_City__c= acc.City__c;
            samObj.Ship_To_Postal_Code__c= acc.Postal_Code__c;
 
Best Answer chosen by Michele Toscano
SalesFORCE_enFORCErSalesFORCE_enFORCEr
You have to make it not null to cover the code.

All Answers

SalesFORCE_enFORCErSalesFORCE_enFORCEr
You have to make it not null to cover the code.
This was selected as the best answer
Amit Chaudhary 8Amit Chaudhary 8
Please post your full code.

NOTE:- you need to pull some value in your listacc list. If you are using any SOQL then create some data according to your query.