You need to sign in to do that
Don't have an account?

Test Class Coverage
trigger AddQuickLead on Lead (after insert) { for (Lead l : Trigger.new) { Quick_Lead__c reg = new Quick_Lead__c( Name=l.Name, Email__c = l.Email, Street_Address__c = l.Street, city__c = l.City, state__c = l.State, Country__c = l.Country ); if(l.FirstName==null) { reg.Name= l.LastName; } else { reg.Name= l.FirstName+''+''+l.LastName; } insert reg; }
how to get coverage for line:
reg.Name= l.FirstName+''+''+l.LastName;
Hi ,
Insert two reccords in the test one with first name null and other one tih some value in it. This will cover the if and else part. So that should cover the line which you have pointed out.
Hope it help!!
Regards
Sam
Here is the test class
I would add a system.AssertEquals
if you added your test data as testLead1.add(new Lead(FirstName = 'Mary', LastName = 'Smith', Company='Widgets and Co', Email='sd462fe@sdsdfs.com', City = 'Herndon'.....
then you could assert that the name is equal to FirstName + LastName:
Quick_Lead__c ql = [select id, Name from Quick_Lead__c where createdDate = TODAY and City__c = 'Anytown'];
system.AssertEquals(ql.Name,'Mary Smith');