//Test class for visualforce (VF) page with URL parameters
/*
Here i am creating test class for standard controller as well when we want to pass parameters in URL
*/
@isTest
public class VFTestClass
{
static testmethod void VFPageControllerTest()
{
Test.startTest();
insert account; //Insert an account
PageReference pageRef = Page.VFPAGENAME;
pageRef.getParameters().put('id', account.id); // URL parameter "id"
Test.setCurrentPage(pageRef);
ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(account);
CLASSNAME classInstanat = new CLASSNAME(sc);
classInstanat.SaveRecord(); // method in controller class
test.stopTest();
}
}
/*
Here i am creating test class for standard controller as well when we want to pass parameters in URL
*/
@isTest
public class VFTestClass
{
static testmethod void VFPageControllerTest()
{
Test.startTest();
insert account; //Insert an account
PageReference pageRef = Page.VFPAGENAME;
pageRef.getParameters().put('id', account.id); // URL parameter "id"
Test.setCurrentPage(pageRef);
ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(account);
CLASSNAME classInstanat = new CLASSNAME(sc);
classInstanat.SaveRecord(); // method in controller class
test.stopTest();
}
}