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
satya G 4satya G 4 

how test coverage for this query

update_c up=[SELECT Id,Name,updateopportunity__c,UpdatedAccountBy__c,updatecontact__c,updatecontact__r.Name,updatecontact__r.Email,updateBycontact__c,updateBycontact__r.Name,updateBycontact__r.Email,updatelead__r.Company,UpdateLeadBy__r.Name,UpdateLeadBy__r.Email,updatelead__c,UpdateLeadBy__c,updateAccount__c  FROM Update__c WHERE updateAccount__r.Id = :opp.AccountId AND (updateBycontact__r.Email!=null or UpdateLeadBy__r.Email!=null) ];
This is query in trigger so in test class,i insert a record on update_c like:Update__c  rf = new Update__c();
        rf.Name = 'TestReferral';
        rf.updateBycontact__c = con.Id;
        rf.UpdateLeadBy__c = ld.Id;
        rf.updatecontact__c = c.Id;
        rf.updatelead__c = l.Id;
        rf.updateAccount__c =opp.AccountId;
        //rf.updateAccount__c='00128000018abGD';
        rf.UpdatedAccountBy__c=opp.AccountId;
        
        insert rf;  
so,i need to satisfy the query in test class right..,wt should i do & how to get these values here
System.debug('>>>>>>>rf.updateAccount__c>>>>>>>'+rf.updateAccount__c);
        System.debug('>>>>>>>rf.updateBycontact__r.Email>>>>>>>'+rf.updateBycontact__r.Email);
        System.debug('>>>>>>>rf.updateAccount__r.id>>>>>>>'+rf.updateAccount__r.Id);
        System.debug('>>>>>>>rf.UpdateLeadBy__r.EMAIL>>>>>>>'+rf.UpdateLeadBy__r.Email);
        
while inert a update_c record,we can't get the parent record fields like above mails.so agian i queried on up_c objct,eventhough i didnt get:
rf=[Select id,Name,updateBycontact__c,UpdateLeadBy__c,updatecontact__c,updatelead__c,updateAccount__c,UpdatedAccountBy__c From Update__c  WHERE updateAccount__r.Id = :opp.AccountId AND (updateBycontact__r.Email!=null or UpdateLeadBy__r.Email!=null) ];
how to do.

Thanks & regards