Salesforce
PDII · Question #338
A developer wrote a test class that successfully asserts a trigger on Account. It fires and updates data correctly in a sandbox environment. A Salesforce admin with a custom profile attempts to…
The correct answer is B. Add System.runAs() to the test class to execute the trigger as a user with the correct object. See the full explanation below for the reasoning.
Question
A developer wrote a test class that successfully asserts a trigger on Account. It fires and updates data correctly in a sandbox environment. A Salesforce admin with a custom profile attempts to deploy this trigger via a change set into the production environment, but the test class fails with an insufficient privileges error. What should a developer do to fix the problem?
Options
- AVerify that Test.startTest() is not inside a FOR loop in the test class.
- BAdd System.runAs() to the test class to execute the trigger as a user with the correct object
- CAdd seeAllData=true to the test class to work within the sharing model for the production
- DConfigure the production environment to enable "Run All Tests as Admin User."
How the community answered
(33 responses)- A3% (1)
- B76% (25)
- C6% (2)
- D15% (5)
Community Discussion
No community discussion yet for this question.