Salesforce Platform Developer I (legacy) — Question 264
Which scenario is valid for execution by unit tests?
Answer options
- A. Load data from a remote site with a callout.
- B. Execute anonymous Apex as a different user.
- C. Set the created date of a record using a system method.
- D. Generate a Visualforce PDF with getContentAsPDF().
Correct answer: C
Explanation
The correct answer, C, is valid because unit tests can use system methods to manipulate record attributes without causing side effects. Options A and D involve external dependencies or operations that can lead to unpredictable results, while B requires a level of permissions that is not suitable for unit tests.