You need to sign in to do that
Don't have an account?
sridhar sridhar
Catch block not able to get code coverage & Apexpages.Addmessage
Hi,
I am not able to get code coverage for the the catch block..
how to get test code coverage for this.
thanks
}catch(exception e){
o=null;
Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'The URL entered is not exist.'));
errorMessage=true;
}
I am not able to get code coverage for the the catch block..
how to get test code coverage for this.
thanks
}catch(exception e){
o=null;
Apexpages.addMessage(new ApexPages.Message(ApexPages.Severity.FATAL, 'The URL entered is not exist.'));
errorMessage=true;
}
Can you provide sample cod
Not all code that is written can be covered. This is a fact of salesforce.com development. There is a reason why the deployment rule is 75% coverage, and not 100% coverage. This "wiggle room" exists so that developers can test the majority of their code, since exception handling can be hard to troubleshoot and even harder to test through scripting, since errors are supposed to be the exception, not the rule. The important thing about your test methods is that they verify your code works correctly. Unless you have a way of crafting a record that will fail, the only other method-- which is strongly not recommended-- would be to write a exception built into the actual code you're testing. This involves using Test.isRunningTest to set up an arbitrary failure
Hope it will help you:)
Please choose as best answer
Thanks