function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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();
}

}