4
votes
Accepted
Test class coverage required for Custom metadata that turns a Trigger on and Off
You have here a great example of why you should not put your code in a trigger body, but rather in a class. If you put this flag in your handler instead, you can just hook it up to a static variable ...
- 147k
2
votes
How to cover try and catch block in test apex class
Will the exception ever actually occur? For conditions you don't plan on happening best not to add exception handling and allow the exception to pass up and be reported.
If the exception handling is ...
- 133k
2
votes
How to cover try and catch block in test apex class
Try to execute your method wrapped in the try-catch block in your unit test method. It will catch the exception and you can assert if it was really caught.
@IsTest
static void testMethodException() {
...
2
votes
how can you increase code coverage without modifying test class?
As a short, pithy remark: you can't
If you need additional coverage, then the only correct way to go about doing that is by adding additional tests (making a new test class, adding tests to the ...
- 54.9k
1
vote
Test class coverage required for Custom metadata that turns a Trigger on and Off
Another way to handle this would be to make a proxy class that is responsible for accessing Custom Metadata Type records (instead of accessing them directly). Having this additional layer gives you ...
- 54.9k
1
vote
How to write test class for this?
You can follow below steps -
Prepare data in @testSetup - create account and contact with status__c and accountId of inserted account.
Create a @isTest method and query the account. Call the ...
- 558
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
code-coverage × 1295apex × 855
unit-test × 810
trigger × 187
failing-tests × 99
deployment × 64
batch × 55
visualforce × 42
class × 40
code × 37
test-setup × 32
callout × 26
scheduled-apex × 25
httpcalloutmock × 23
salesforcedx × 22
developer-console × 20
controller × 18
rest-api × 17
wrapper-class × 14
change-set × 14
before-trigger × 13
schedulebatch × 13
lightning-web-components × 11
json × 11
try-catch × 11