• JessFeau
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I have a custom controller where I have a set of conditional statements (if, else if) to set the mail.setTemplateId.  I am trying to write a test class to cover these if statements but I can't figure out how to use TemplateId for the test.
I have a custom controller where I have a set of conditional statements (if, else if) to set the mail.setTemplateId.  I am trying to write a test class to cover these if statements but I can't figure out how to use TemplateId for the test.
Hi Everyone,

I need a test class code which covers the below lines of code:
I am unable to cover the code for exception mail code
/* @purpose : Send the exception email to the user who started the batch job
    */    
    public static void sendExceptionEmail(Exception e) {
        Messaging.SingleEmailMessage message = new Messaging.SingleEmailMessage();
        message.setTargetObjectId(UserInfo.getUserId());
        message.subject = 'Batch job failed to create Pickup request on ' + System.now().format('MM/dd/yyyy HH:mm:ss');
        message.saveAsActivity = FALSE;
        message.plainTextBody = 'Exception while creating Pickup requests ' + e.getMessage() + '\n' + e.getStackTraceString();
        Messaging.SingleEmailMessage[] messages = 
            new List<Messaging.SingleEmailMessage> {message};
                Messaging.SendEmailResult[] results = Messaging.sendEmail(messages);
    }

Kindly help me

Thanks & Regards,
Harjeet