PDI · Question #168
A develop completed modification to a customized 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…
The correct answer is A. Apex classes must have at least 75% code coverage org-wide. B. At least one line of code must be executed for the Apex trigger. For deployment to production, individual Apex classes must achieve at least 75% code coverage, and Apex triggers must have at least one line of code covered by unit tests.
Question
A develop completed modification to a customized 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 the modification to the production environment?
Options
- AApex classes must have at least 75% code coverage org-wide.
- BAt least one line of code must be executed for the Apex trigger.
- CAll methods in the test classes must use @isTest.
- DTest methods must be declared with the testMethod keyword.
How the community answered
(20 responses)- A95% (19)
- C5% (1)
Why each option
For deployment to production, individual Apex classes must achieve at least 75% code coverage, and Apex triggers must have at least one line of code covered by unit tests.
Salesforce requires that Apex classes have at least 75% code coverage by test methods to be deployed to a production environment, and this generally contributes to the overall org-wide coverage.
Although Apex triggers do not require 75% code coverage, they must have at least one line of code executed by a test method to be successfully deployed to production.
Not all methods within a test class must use the `@isTest` annotation; only the class itself needs it, or individual methods can be marked `testMethod` if the class is not annotated.
Test methods can be declared with the `testMethod` keyword, but they can also simply be public static methods within a class annotated with `@isTest`.
Concept tested: Apex Code Deployment Requirements
Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_code_test_methods.htm
Topics
Community Discussion
No community discussion yet for this question.