function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
richard1.3903050990828992E12richard1.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);
}
Tarun J.Tarun J.
Hello Richard,

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
richard1.3903050990828992E12richard1.3903050990828992E12
Hi Tarun. Forgive me - which code block on that page are you referring to?