You need to sign in to do that
Don't have an account?
jburns12
Help with test Code
trigger Base_TR_ConvertLead on Lead (after insert, after update) { //create a string of ids to be converted String records = ''; //get all records with status Lead Status= Qualified for(Lead lead : Trigger.New) { if(lead.Status == 'Qualified') { if(records == '') records = lead.Id; else records = records + ',' + lead.Id; } } //call the single click lead convert method to convert the lead if(records != '') { MassConvert.MassLeadConvert.ConvertRecords(records, true, true, '','',true, 'Auto Convert'); } }
I need help writing the test code for this trigger, I am new to Apex and not very sure of myself. Can some one give me a test example?
The only thing you need to do is create two leads, one "Qualified" and one not "Qualified" and then assert that the leads went through.
Try out this sample code of testclass given below :
static testMethod void testrunmethod()
{
Lead lead = new Lead();
lead.status = "Qualified";
insert lead;
}
static testMethod void testrunmethod()
{
Lead lead1 = new Leas();
lead1.status = "Open";
insert lead1;
}
Hope this helps.