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