You need to sign in to do that
Don't have an account?

how to cover test class for try catch block Messaging..sendEmail
Hi,
try {
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
}
} catch (Exception e) {
System.debug('Exception'+e.getMessage());
throw e;
}
I can' t get the code coverage for catch block.
Tried the below,
try {
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
if(Test.isRunningTest()) {
throw new EmailException('Email Exception occurred for testing');
}
} catch (Exception e) {
System.debug('Exception'+e.getMessage());
throw e;
}
Getting 100% coverage but the test class is failing.
Please help me out here
Hi,
I have tested your code and it is not showing any error. Your code coverage is 80% if you call simply like that
Test Class:
Please mark it as the Best Answer if it helps you.
Thank You