Salesforce Certified Platform Developer II — Question 116
What is a best practice when unit testing a controller? (Choose two.)
Answer options
- A. Simulate user interaction by leveraging Test.setMock()
- B. Verify correct references by using getURL()
- C. Access test data by using seeAllData=true
- D. Set query parameters by using getParameters().put
Correct answer: B, D
Explanation
The correct answers are B and D because verifying correct references with getURL() ensures that the controller is functioning as intended, while setting query parameters with getParameters().put is essential for simulating different scenarios in tests. Options A and C are not best practices, as simulating user interaction should be avoided in unit tests, and accessing all test data can lead to dependencies on non-isolated test cases.