You need to sign in to do that
Don't have an account?
Apex code Coverage
Hi Friends,
I write a code for trigger and it has no errors also it works successfully but code coverage is 0%.
Can any one suggest for a solution.
trigger email on Lead (after insert)
{
string leadId = trigger.new[0].id;
list<lead > lstlead =[select id,email from lead where id=:leadId];
string leademail =lstlead[0].email;
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setUseSignature(false);
mail.setToAddresses(new String[] { leademail });
mail.setSubject('Document Email Demo');
mail.setHtmlBody('Here is the email you requested');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
Regards,
Srikanth
Do you have a test class for this trigger, or any test class that inserts a lead?
If not, I'd start by taking a look at this wiki page on developerforce:
http://wiki.developerforce.com/page/How_to_Write_Good_Unit_Tests
Hi Bob_buzzard,
Can you post a test code for above Apex code;
Regards,
Srikanth
It shouldn't be difficult - by the look of it you just need a test method that creates a lead containing an email address. If you want to have a stab at it I'll help if you get stuck.