Valid PDI Dumps shared by ExamDiscuss.com for Helping Passing PDI Exam! ExamDiscuss.com now offer the newest PDI exam dumps, the ExamDiscuss.com PDI exam questions have been updated and answers have been corrected get the newest ExamDiscuss.com PDI dumps with Test Engine here:
A developer has a single custom controller class that works with a Visualforce Wizard to support creating and editing multiple sObjects. The wizard accepts data from user inputs across multiple Visualforce pages and from a parameter on the initial URL. Which three statements are useful inside the unit test to effectively test the custom controller? Choose 3 answers
Correct Answer: A,B,D
A: Thesave()method in the custom controller must be tested to ensure it works as intended and redirects to the correct page. B: Setting parameters viaApexPages.currentPage().getParameters()is crucial to test scenarios where user input or URL parameters drive logic. D: UsingTest.setCurrentPage(pageRef)is essential for simulating page context in unit tests. Why not other options? C: This statement does not belong to testing a custom controller. B (second occurrence): It appears to be incorrectly formatted in the question. Testing Apex Controllers
Recent Comments (The most recent comments are at the top.)
Yassine - Oct 21, 2026
Answer: A, B and E
E. Test.setCurrentPage(pageRef): This sets which Visualforce page the test is running on. It is the starting point for a wizard test, because ApexPages.currentPage() doesn’t exist until you set one. B. ApexPages.currentPage().getParameters().put('input', 'TestValue'): The wizard reads a parameter from the initial URL, so the test has to supply that parameter. (The option’s text is garbled by OCR, and I’m reading it as this statement.) A. String nextPage = controller.save().getUrl(): This calls a controller action and checks the PageReference it returns. In a wizard, the next page is the thing to assert on at each step. apex @isTest private class WizardControllerTest { @isTest static void testWizardStep() { PageReference pageRef = Page.WizardStep1; Test.setCurrentPage(pageRef); // E ApexPages.currentPage().getParameters().put('input', 'TestValue'); // B
WizardController controller = new WizardController(); controller.name = 'Test'; // simulate user input
String nextPage = controller.save().getUrl(); // A System.assert(nextPage.contains('wizardstep2')); } }
The other options don’t fit:
C. insert pageRef;: A PageReference isn’t an sObject, so you can’t insert it. The statement doesn’t compile. D. public ExtendedController(ApexPages.StandardController ctrl) {}: This is a constructor declaration for a controller extension. It belongs in the controller class, not in a test, and the question is about a custom controller, not an extension....
Recent Comments (The most recent comments are at the top.)
Answer: A, B and E
E. Test.setCurrentPage(pageRef): This sets which Visualforce page the test is running on. It is the starting point for a wizard test, because ApexPages.currentPage() doesn’t exist until you set one.
B. ApexPages.currentPage().getParameters().put('input', 'TestValue'): The wizard reads a parameter from the initial URL, so the test has to supply that parameter. (The option’s text is garbled by OCR, and I’m reading it as this statement.)
A. String nextPage = controller.save().getUrl(): This calls a controller action and checks the PageReference it returns. In a wizard, the next page is the thing to assert on at each step.
apex
@isTest
private class WizardControllerTest {
@isTest
static void testWizardStep() {
PageReference pageRef = Page.WizardStep1;
Test.setCurrentPage(pageRef); // E
ApexPages.currentPage().getParameters().put('input', 'TestValue'); // B
WizardController controller = new WizardController();
controller.name = 'Test'; // simulate user input
String nextPage = controller.save().getUrl(); // A
System.assert(nextPage.contains('wizardstep2'));
}
}
The other options don’t fit:
C. insert pageRef;: A PageReference isn’t an sObject, so you can’t insert it. The statement doesn’t compile.
D. public ExtendedController(ApexPages.StandardController ctrl) {}: This is a constructor declaration for a controller extension. It belongs in the controller class, not in a test, and the question is about a custom controller, not an extension....
Correct Answer: A,B,E*