Activity Forums Salesforce® Discussions Why should we use the Test.setCurrentPage() method in Test class on salesforce?

  • Regula

    Member
    November 7, 2016 at 6:21 pm

    it is used to set the context to current page

  • shariq

    Member
    September 19, 2018 at 1:33 pm

    Hi,

    setCurrentPage(page) :
    A Visualforce test method that sets the current PageReference for the controller.

    Thanks

  • Parul

    Member
    September 19, 2018 at 5:17 pm

    Add some ex:

    public class thecontrollerTests {

    public static testMethod void testMyController() {
    PageReference pageRef = Page.success;//Observe how we set the Page here
    Test.setCurrentPage(pageRef);//Applying page context here

     

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos