Find your content:

Search form

You are here

what to write test cases for Site.ChangePassword();

 
Share
PageReference pf = Site.changePassword(newPassword, verifyNewPassword, oldPassword); 

This pf object always return null and i am unable to cover the lines after this line.


Attribution to: upgoingstar

Possible Suggestion/Solution #1

You can use Test.isRunningTest() to simulate anything you want after the call during test execution.

E.g.

PageReference pf = Site.changePassword(newPassword, verifyNewPassword, oldPassword);
if(Test.isRunningTest()) {
    pf = new PageReference('http://salesforce.stackexchange.com/');
}
// Remaining lines that depend on the PageReference.

Attribution to: Daniel Ballinger
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/31726

My Block Status

My Block Content