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

Lead test class is not covering the list


  For Class   
public class LeadTriggerUtils {
    public static void processLeadOnUpdate(Map<id, Lead> newMap, Map<id, Lead> oldMap) { 
        List<Lead> leadLst = new List<Lead>();
        for (Lead lead : newMap.values()) {
            Lead oldLead = oldMap.get(;
            if(lead.rvpe__IsDealRegistration__c && lead.rvpe__RVAccount__c != null && lead.rvpe__RVAccount__c != oldLead.rvpe__RVAccount__c) {
        if(!leadLst.isEmpty()) {
    public static void processLeadOnInsert(List<Lead> newLst) {
    public static void processChangeOwnerAsPartnerAccount(List<Lead> newLst) {
        List<ID> rvAcctIDs = new List<ID>();
        for(Lead lead : newLst) {
            if(lead.rvpe__IsDealRegistration__c && (lead.Global_Region__c == 'EMEA' || lead.Global_Region__c == 'LATAM') && lead.rvpe__RVAccount__c != null) {
        Map<ID, rvpe__RVAccount__c> rvActMap = new Map<Id, rvpe__RVAccount__c>([select id, rvpe__SFAccount__c, rvpe__SFAccount__r.OwnerId from rvpe__RVAccount__c where id in :rvAcctIDs]);
        for(Lead lead : newLst) {
            rvpe__RVAccount__c rvAct = rvActMap.get(lead.rvpe__RVAccount__c);
            if(rvAct != null && rvAct.rvpe__SFAccount__c != null) {
                lead.OwnerId = rvAct.rvpe__SFAccount__r.OwnerId;

Below is the test class it has 90% code coverage. 
@isTest(seealldata = true)
public class LeadTriggerUtilsTest{
        public static void leadTest(){
          rvpe__RVAccount__c rpv = [select id from rvpe__RVAccount__c where rvpe__SFAccount__c <> null and rvpe__PartnerLevel__c = 'NA Reseller' limit 1];
            Lead l1 = new Lead();
            l1.FirstName = 'Pranavan';
            l1.LastName = 'Karthi';
            l1.Email = '';
            l1.Company = 'Pranavan';
   = 'United States';
            l1.rvpe__IsDealRegistration__c = true;
            l1.Global_Region__c = 'EMEA'; 
            l1.rvpe__RVAccount__c =;
            insert l1;
            l1.FirstName = 'Velu';
            update l1;
       public static void leadTest_two(){
        Lead l = [select id from lead where rvpe__IsDealRegistration__c  = true and Global_Region__c  <> null and rvpe__RVAccount__c  <> null limit 1];
        l.firstname = 'sudhir';
        update l;
Only below lines are not covered. 
User-added image
When I try to deploy in production it is giving code coverage error.  Please suggest me how to fix. 

Hi ,

It is not going inside the IF condition because the below condition is not satisfied.
lead.rvpe__RVAccount__c != oldLead.rvpe__RVAccount__c

both the accounts in oldmap and is same.
Thanks for your reply i have 90% code coverage do you know why I keep getting code coverage when i try to validate in production.
Ajay K DubediAjay K Dubedi
Hi  MaheemSam,

Have a look at this thread :

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Ajay Dubedi