You need to sign in to do that
Don't have an account?
Romeo Mirzac
Apex Unit Testing Problem
After adding error checking to my Apex classes (try..catch blocks), my apex unit tests are now less than 100%. Apparently I'm not testing for the Catch part of my code. I can't for the life of me figure out how to test for this. Help!
Thanks.
My catch blocks are all like this:
Catch (Exception ex) {
String strMsg = 'An error occurred: ' + ex;
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, strMsg);
ApexPages.addMessage(myMsg);
}
Thanks.
My catch blocks are all like this:
Catch (Exception ex) {
String strMsg = 'An error occurred: ' + ex;
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, strMsg);
ApexPages.addMessage(myMsg);
}
Best Answer chosen by Romeo Mirzac
Michael Verhovski
There are several good examples of exception testing in How to Write Good Unit Tests (https://developer.salesforce.com/page/How_to_Write_Good_Unit_Tests) article