PDI practice question 15 of 30

A developer completed modifications feature that is comprised of two elements: * Apex trigger * Trigger handler Apex class What are two factors that the developer must take into account to properly deploy them to the production environment? Choose 2 answers

Full set: 201 questions
Answer options
A: Apex classes must have at least 75% code coverage org-wide. Correct answer
B: All methods in the test classes must use @istest.
C: At least one line of code must be executed for the Apex trigger. Correct answer
D: Test methods must be declared with the testMethod keyword.
Correct Answer:
A. Apex classes must have at least 75% code coverage org-wide.; C. At least one line of code must be executed for the Apex trigger.
Explanation

When deploying Apex code to a production environment, Salesforce enforces specific code coverage requirements to ensure code quality and reliability. The developer must ensure that the Apex classes and triggers being deployed achieve a cumulative code coverage of at least 75%. Additionally, a specific rule applies to triggers: every trigger included in the deployment must have at least one line of code executed by a test method, meaning its coverage must be greater than 0%. Both of these conditions must be met for the deployment to succeed.

Why Incorrect

B. All methods in the test classes must use @istest. This is incorrect. Test classes can include helper methods (e.g., for creating test data) that are not actual tests and therefore are not annotated with @isTest.
D. Test methods must be declared with the testMethod keyword. This is incorrect. The testMethod keyword is a legacy syntax. The current, standard practice is to use the @isTest annotation to define test methods.

References

1. 75% and Trigger Coverage Rule: The Apex Developer Guide explicitly states the deployment requirements.

"Before you can deploy your code or package it for the AppExchange, at least 75% of Apex code must be covered by tests, and all those tests must pass... Also, every trigger must have some test coverage."

Source: Salesforce Apex Developer Guide, "Run Unit Test Methods", Section: Code Coverage Requirements.

2. @isTest Annotation vs. testMethod Keyword: The documentation clarifies the modern standard for defining test methods.

"Methods of a test class that are test methods must be annotated with @isTest... Alternatively, test methods can be defined with the testMethod keyword, but this is an older syntax."

Source: Salesforce Apex Developer Guide, "Apex Annotations", Section: @isTest Annotation.

3. Helper Methods in Test Classes: The documentation provides examples showing that not all methods in a test class are test methods.

"A test class is a class that is annotated with @isTest... Test classes can also have methods that are not test methods. These methods are typically helper methods that are called by test methods."

Source: Salesforce Apex Developer Guide, "Execution Governors and Limits", Section: Per-Transaction Apex Limits (context on test methods and their structure).

Scroll to Top