You need to sign in to do that
Don't have an account?
sona gaikwad
How to write a test class for an apex trigger on lead
trigger
trigger MyTrigger on Lead (before insert,before update) {
leadhandlerclass handler =new leadhandlerclass();
if(Trigger.isInsert && Trigger.isbefore)
{
handler.UpdateLeadStatus(Trigger.new);
}
if(Trigger.isupdate && Trigger.isbefore)
{
handler.UpdateLeadStatus(Trigger.new);
}
}
Testlead
@istest
private class Testlead {
static testmethod void addressOverride(){
Lead s = new Lead();
s.stages__c = 'Booked';
leadhandlerclass handler =new leadhandlerclass();
Lead acc = new Lead (stages__c = 'Booked');
insert acc;
system.debug('----->>> stages__c: ' + acc.stages__c);
Test.startTest();
system.debug('----->>> status__c: ' + acc.status__c);
Test.stopTest();
}
}
trigger MyTrigger on Lead (before insert,before update) {
leadhandlerclass handler =new leadhandlerclass();
if(Trigger.isInsert && Trigger.isbefore)
{
handler.UpdateLeadStatus(Trigger.new);
}
if(Trigger.isupdate && Trigger.isbefore)
{
handler.UpdateLeadStatus(Trigger.new);
}
}
Testlead
@istest
private class Testlead {
static testmethod void addressOverride(){
Lead s = new Lead();
s.stages__c = 'Booked';
leadhandlerclass handler =new leadhandlerclass();
Lead acc = new Lead (stages__c = 'Booked');
insert acc;
system.debug('----->>> stages__c: ' + acc.stages__c);
Test.startTest();
system.debug('----->>> status__c: ' + acc.status__c);
Test.stopTest();
}
}
Below Code can fulfill your requirements, Hope this will work for you.
Please mark this as best answer if this solves your problem.
Thank you,
Ajay Dubedi
All Answers
Below Code can fulfill your requirements, Hope this will work for you.
Please mark this as best answer if this solves your problem.
Thank you,
Ajay Dubedi