You have to create an exception in your test code to cover the catch block . You can create in varous ways according to your need . One way here is there in Forum you can cehck below link . https://developer.salesforce.com/forums?id=906F0000000B1x5IAC
You just need to add following line at the end of your try block.
if(Test.isRunningTest()){
Integer x=1/0;
}
These lines throws exception and then catch block will be covered.
I think it will be help you.
All Answers
You just need to add following line at the end of your try block.
if(Test.isRunningTest()){
Integer x=1/0;
}
These lines throws exception and then catch block will be covered.
I think it will be help you.
You have to create an exception in your test code to cover the catch block . You can create in varous ways according to your need .
One way here is there in Forum you can cehck below link .
https://developer.salesforce.com/forums?id=906F0000000B1x5IAC
If you need any help please let me know .