Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.
PageReference pf = Site.changePassword(newPassword, verifyNewPassword, oldPassword); 

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

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.