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?
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';
}
}
}
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);
}
}
}
The trigger is much longer than that, but just included a few lines for reference.