You need to sign in to do that
Don't have an account?
tulasi ram 1
How to include catch block in code coverage
I am using below code
Unable to include catch block in code coverage. How can we include this catch blocks in code coverage.
global static String updateContact(Contact objContact) { try{ if(isContactUpdateable() || Test.isRunningTest()) { update objContact; return 'Contact updated successfully!'; } else { return 'Insufficient access to update contact, please contact system admin for more information'; } }catch(Exception ex) { return '' + ex.getMessage(); } }
Unable to include catch block in code coverage. How can we include this catch blocks in code coverage.
I trust you are doing very well.
Please refer to the below link with a similar discussion which might help you further with the above issue.
https://developer.salesforce.com/forums/ForumsMain?id=906F000000092nNIAQ
See answer from bob_buzzard in this link.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas
but it is giving unreachable statement error. And it is saying that 'throw new Exception();' is not defined.
You need to add below line of code in your class, above your method.
Regards,
Khan Anas