Sample Apex Class:
public class Sample {
public Sample() {
}
public PageReference goToInfallible() {
PageReference pg = new PageReference(‘https://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!!!
how is the assertion done?
Check this for assertions in the test class for PageReference – http://www.infallibletechie.com/2018/07/how-to-cover-pagereference-method-in.html