+ Start a Discussion
ankitha varraankitha varra 

How to test the site.login(username, password, startUrl) in salesforce

Hai,
  there  is a scenario there i want to test site.login(username,password,starturl)  in salesforce
Rito SarkarRito Sarkar
as this method returns a pagereference, ithink this will do, u can test any method of pageReference return type using this.


@isTest
private class testLogin{
//this is mandatory declaration
private static Pagereference newPage;
//this declaration is optional
private static yourclass variableofClasstype;

private static testmethod void myTestmethod(){
Test.startTest();
//this is optional
variableofClasstype=new yourClass();
//this is mandatory
newPage=site.login(username,password,startURL);
Test.stopTest();
}

}