Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam CRT-450 All Questions

View all questions & answers for the CRT-450 exam

Exam CRT-450 topic 1 question 352 discussion

Actual exam question from Salesforce's CRT-450
Question #: 352
Topic #: 1
[All CRT-450 Questions]

While working in a sandbox, an Apex test falls when run in the Test Framework. However, running the Apex test logic in the Execute Anonymous window succeeds with no exceptions or errors.

Why did the method fall in the sandbox test framework but succeed in the Developer Console?

  • A. The test method is calling an @future method.
  • B. The test method has a syntax error in the code.
  • C. The test method does not use System.runAs to execute as a specific user.
  • D. The test method relies on existing data in the sandbox.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
wlthorn
1 year, 8 months ago
Anyone know if these are the latest exam questions?
upvoted 3 times
...
Jason_R
1 year, 10 months ago
The answer is C. "The test method does not use System.runAs to execute as a specific user." "Generally, all Apex code runs in system mode, where the permissions and record sharing of the current user aren’t taken into account. The system method runAs enables you to write test methods that change the user context to an existing user or a new user so that the user’s record sharing is enforced. The runAs method enforces record sharing. User permissions and field-level permissions are applied for the new context user as described in Enforcing Object and Field Permissions." https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_tools_runas.htm
upvoted 1 times
Bill1232
1 year, 1 month ago
don't know, if the user running the test is the same as the user running Anonymous tool runAs doesn't matter, the context user is the same, it's the same code but with error in test case, i'm thinking the D is the right one, @future doesn't make sense, if it was syntax error the error were to be fired in the two cases.
upvoted 2 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...