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

Testing AuraHandledException in Test Class
Hi all,
I have some apex code that looks like the code below. In my test class, I have a testMethod for successful execution, but I'm having trouble creating a testMethod for the exception. I've been able to trigger the exception, but the test is marked as Fail and I recieve "System.AuraHandledException: Script-thrown exception". As a result, I'm not getting code coverage for this exception.
How can I successfully test an AuraHandledException from a testMethod without breaking the test and having it result in a Fail?
I have some apex code that looks like the code below. In my test class, I have a testMethod for successful execution, but I'm having trouble creating a testMethod for the exception. I've been able to trigger the exception, but the test is marked as Fail and I recieve "System.AuraHandledException: Script-thrown exception". As a result, I'm not getting code coverage for this exception.
How can I successfully test an AuraHandledException from a testMethod without breaking the test and having it result in a Fail?
try{ update account; } catch(Exception e){ throw new AuraHandledException('error updating account'); }
account.name = '';
try
{
//call the above method which updates the account
}
catch(Exception e)
{
}
All Answers
account.name = '';
try
{
//call the above method which updates the account
}
catch(Exception e)
{
}
It resolved my issue with a try-catch block in my test class.
Learn More
https://allfinancedeals.com/online-banks-that-use-zelle.html
https://allfinancedeals.com/link-bank-account-to-cash-app-without-debit-card.html
https://allfinancedeals.com/can-you-add-money-to-venmo-card-at-atm.html
https://allfinancedeals.com/pay-for-pizza-with-routing-number.html
https://allfinancedeals.com/how-to-shop-online-with-a-stolen-credit-card.html
https://allfinancedeals.com/gift-card-sites-that-accept-paypal.html
https://allfinancedeals.com/how-to-use-google-pay-at-atm.html
https://allfinancedeals.com/how-to-use-virtual-visa-card-in-store.html
https://allfinancedeals.com/pay-for-food-with-bank-account-number.html
Allfinancedeals.com is a website that always believes in reality and authentic information about all types of financial activities. We are committed to providing you with all types of creative financial solutions that will need for yourself, your family, and your friends.