• Travis Dvorak
  • NEWBIE
  • 10 Points
  • Member since 2017


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 3
    Replies
I have a working trigger that I'm starting to build my test class for.  I've done a few lines and ran a test to make sure it's working as it should and everything seems okay, except the trigger itself is 0% coverage.  Can someone help me figure out why?  I'm an amature with this stuff, so please go easy on me if it's something very simple.

Trigger:
trigger PartnerLeadAssignment on Lead (before insert) {
    
    List<Lead> leadList = new List<Lead>();
    for(Lead l : trigger.new){
        leadList.add(l);
        if(l.Company == null){
            l.Company = l.FirstName + ' ' + l.LastName;
        
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002SuHKtQAN'){
                l.OwnerId = '0050H0000090O6HQAU';
                }

            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002Vv9gqQAB'){
                l.OwnerId = '0050H00000BwRULQA3'; 
                }    
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002PZz8zQAD'){
                l.OwnerId = '0050H000009LmB3QAK';
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000001siaFLAAY'){
                l.OwnerId = '005i0000007xZy2AAE';
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000001R92ADAAZ'){
                l.OwnerId = '005i0000004jpjbAAA';  
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002LTwKnQAL'){
                l.OwnerId = '0050H0000090Mz0QAE';  
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000000Rr2XRAAZ'){
                l.OwnerId = '005i0000006ozUbAAI'; 
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000001lbahkAAA'){
                l.OwnerId = '005i0000007CtxhAAC';  
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002WhyBJQAZ'){
                l.OwnerId = '0050H00000BNF5XQAX';  
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002Gbu8mQAB'){
                l.OwnerId = '0050H00000A9mp3QAB';  
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002QeX7JQAV'){
                l.OwnerId = '0050H0000090IR1QAM';  
                } 
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002Wk18hQAB'){
                l.OwnerId = '0050H00000BwWykQAF';  
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002QeXBVQA3'){
                l.OwnerId = '0050H0000090HG2QAM';  
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002JJNojQAH'){
                l.OwnerId = '0050H000009LjrVQAS';  
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002WhxgEQAR'){
                l.OwnerId = '0050H00000BpsLdQAJ';  
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000001p21CnAAI'){
                l.OwnerId = '005i0000007E1poAAC';  
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000000N2CBbAAN'){
                l.OwnerId = '005i00000058XOlAAM'; 
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '001i000000N2CJ8AAN'){
                l.OwnerId = '005i0000007CVm0AAG'; 
                }
            if(l.LeadSource == 'Website' && (l.Lead_Subtype__c == 'Free Resource' || l.Lead_Subtype__c == 'Contact Requested' || l.Lead_Subtype__c == 'Connect with Advisor' || l.Lead_Subtype__c == 'WMC Footer') && l.Referring_Brand_Id__c == '0010H00002QectbQAB'){
                l.OwnerId = '0050H0000090OXcQAM';  
                }
}
}

Test Class:
 
@isTest
public class PartnerLeadAssignmentTest {
    static testMethod void insertLead(){
        
        List<Lead> leadList = new List<Lead>();
        Lead l = New Lead(Company = '', FirstName = 'First', LastName = 'Last', leadSource = 'Website', lead_SubType__c = 'Contact Requested');
        leadList.add(l);
        if(l.Referring_Brand_Id__c == '0010H00002SuHKtQAN'){  
        
 	       insert l;
        
    	    l=[Select Company, FirstName, LastName, Referring_Brand_Id__c, LeadSource, OwnerId, RecordTypeId FROM Lead Where Id =:l.Id];
        	System.assertEquals('0050H0000090O6HQAU', l.OwnerId);
           }
        if(l.Referring_Brand_Id__c == '0010H00002Vv9gqQAB'){ 
            
            insert l;
            
            l=[Select Company, FirstName, LastName, Referring_Brand_Id__c, LeadSource, OwnerId, RecordTypeId FROM Lead Where Id =:l.Id];
        	System.assertEquals('0050H00000BwRULQA3', l.OwnerId); 
        }
        
        
    }
}

 

Has anyone ever created a formula to proper case fields?

 

Thank you,

Steve