1
vote
Test Code Coverage - Delete DML catch block
You can use the Test.isRunningTest method to check if the code is running in a test context and then throw a custom exception.
For example, you can modify your main class code like this:
@AuraEnabled
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
code-coverage × 1312apex × 863
unit-test × 818
trigger × 191
failing-tests × 103
deployment × 64
batch × 53
class × 41
visualforce × 40
code × 38
test-setup × 33
callout × 25
scheduled-apex × 25
httpcalloutmock × 24
salesforcedx × 20
developer-console × 20
rest-api × 17
controller × 17
apextestrunresult × 15
wrapper-class × 14
change-set × 14
try-catch × 14
before-trigger × 13
schedulebatch × 13
lightning-web-components × 12