You need to sign in to do that
Don't have an account?

Test Coverage for Pagereference method with if statement
I need your assistance to complete test coverage for the following code. How do I add the Pagereference method in my test class and cover the if condition, Thank you!
```
public Pagereference newPage() {
Id classRecordTypeId = Schema.SObjectType.class__c.getRecordTypeInfosByName().get('Staff').getRecordTypeId();
String url = 'https://ourcommunity.force.com/staffportal/List?id=' + classId;
if(classType == classRecordTypeId) {
url += '&type=Staff';
}
return new PageReference(url);
}
Greetings!
Please refer the below thread for the sample code to cover the Pagereference in Test class.
https://developer.salesforce.com/forums/?id=906F00000005KjBIAU
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
All Answers
Greetings!
Please refer the below thread for the sample code to cover the Pagereference in Test class.
https://developer.salesforce.com/forums/?id=906F00000005KjBIAU
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
Hi Shrisha!
I will check it out, thank you for your help.