You need to sign in to do that
Don't have an account?
Mike DeMille
my test class not working
I have a simple trigger that updates a field. My test class is not passing, however gives 80% coverage on the trigger.
Here is the trigger:
trigger Update_MQL on Lead (before insert, before update) {
for (Lead myLead : Trigger.new)
{
if (myLead.MQL_Date__c == null && (myLead.Status =='MQL (Marketing Qualified Lead)' || myLead.Status == 'SAL (Sales Accepted Lead)'))
{myLead.MQL_Date__c = system.today();
}else { myLead.MQL_Date__c = myLead.MQL_Date__c;
}
}
}
Here is the test class:
@isTest
public class TestUpdate_MQL {
static testMethod void insertNewLead() {
Lead newLead = new Lead();
newLead.FirstName = 'Mike';
newLead.LastName = 'DeMille';
newLead.Status = 'MQL (Marketing Qualified lead)';
newLead.LeadSource = 'Advertisment';
insert newLead;
System.assertEquals(system.today(), newLead.MQL_Date__c);
}
}
What needs to be fixed?
Here is the trigger:
trigger Update_MQL on Lead (before insert, before update) {
for (Lead myLead : Trigger.new)
{
if (myLead.MQL_Date__c == null && (myLead.Status =='MQL (Marketing Qualified Lead)' || myLead.Status == 'SAL (Sales Accepted Lead)'))
{myLead.MQL_Date__c = system.today();
}else { myLead.MQL_Date__c = myLead.MQL_Date__c;
}
}
}
Here is the test class:
@isTest
public class TestUpdate_MQL {
static testMethod void insertNewLead() {
Lead newLead = new Lead();
newLead.FirstName = 'Mike';
newLead.LastName = 'DeMille';
newLead.Status = 'MQL (Marketing Qualified lead)';
newLead.LeadSource = 'Advertisment';
insert newLead;
System.assertEquals(system.today(), newLead.MQL_Date__c);
}
}
What needs to be fixed?
Please try above test class let us know if this will help you
All Answers
Please try above test class let us know if this will help you