You need to sign in to do that
Don't have an account?
richard1.3903050990828992E12
Help with test class for trigger notification for deleted accounts
Would someone be able to help me out with a test class for the below (from https://developer.salesforce.com/forums/?id=906F000000094BgIAI) to ensure coverage before I deploy? I am a complete Apex novice and am not getting anywhere with it.
trigger EmailAfterDelete on Account(after delete) { Messaging.reserveSingleEmailCapacity(trigger.size); List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>(); for (Account acct : Trigger.old) { Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setToAddresses(new String[] {'some email address'};); email.setSubject('Deleted Account Alert'); email.setPlainTextBody('This message is to alert you that the account named ' + acct.Name + ' has been deleted.'); emails.add(email); } Messaging.sendEmail(emails); }
You need to insert few Account record and use Delete operation to test this trigger. Kindly refer below link for your reference:
https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
Update the code and add 'delete accounts;' after 'insert accounts;' statement and remove extra code.
-Thanks,
TK