How to cover PageReference method in test class in Salesforce?

Sample Apex Class:

public class Sample {
    public Sample() {
    }
    
    public PageReference goToInfallible() {
        PageReference pg = new PageReference('http://www.infallibletechie.com');
        pg.setRedirect(true);
        return pg;
    }
}

Test class:

@isTest
private class SampleTest {
    @isTest static void test() {
        Sample s = new Sample();
        s.goToInfallible();
    }
}

Cheers!!!

No comments:

Post a Comment