Activity Forums Salesforce® Discussions Test Coverage for Pagereference method with if statement

  • Test Coverage for Pagereference method with if statement

    Posted by Temesgen on December 1, 2020 at 4:26 am

    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);
    }

    Temesgen replied 3 years, 12 months ago 1 Member · 0 Replies
  • 0 Replies

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Popular Salesforce Infographics