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
Varun AnnadataVarun Annadata 

How to cover this code in test class?

set<Id> pmIds = new set<id>();        
        
         for(Medical_History_MVN__c mdh : medicalhistorys) {         
         pmIds.add(mdh.Program_Member_MVN__c); 
             System.debug('mdh:'+mdh);
    }
    
    lstMH = [Select id,Program_Member_MVN__c,Diagnosis_Start_Date_C1__c,Primary_ICD_10_CM_Code_C1__c, Secondary_ICD_10_CM_Code_C1__c, Primary_ICD_10_CM_Code_C1__r.id,
                         Secondary_ICD_10_CM_Code_C1__r.id from Medical_History_MVN__c WHERE RecordType.DeveloperName = 'Diagnosis'
                                                                        and Program_Member_MVN__c IN :pmIds];
How to cover the "pmIds" in test class?
Lokesh KumarLokesh Kumar
HI Varun,

Insert a record of Medical_History_MVN__c in your test class with all the conditions used in SOQL Query.

Medical_History_MVN__c  mh = new Medical_History_MVN__c ( required fields)
 insert mh;

Thanks
Lokesh