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
NLTNLT 

How to do test coverage for below code.

Hi All,
How to do test coverage for below code.
User-added image
Thanks.
Suraj Tripathi 47Suraj Tripathi 47

Hi,

It looks like the code that you want to cover is not running through For Loop. Possible cause - there are no items in the list that you are querying or on which the loop is iterating. 

In the test class, first, create records that satisfy the condition of the apex class in the setup method. 

For more information, how to create test data to cover class, please visit the link below:

https://trailhead.salesforce.com/content/learn/modules/apex_testing/apex_testing_data

Hope this answer will help you. Please mark as the best answer if you are able to resolve your query.

Thanks.