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

How to test redirect in test class
Good day,
Appreciated someone please enlighten me how could i test the current page is the page that re-directed in test class?
for instance,
if i have set my current page from test class
PageReference pageRef = new PageReference('/apex/mycurrentpage);
Assume one method executed later and the method call redirect to another page at the end.
my question is how should i write a test method for it ?
try using following, but it give me pagereference of '/apex/mycurrentpage', what i expecting is '/apex/nextpage'
PageReference curpageRef = ApexPages.currentPage();
Test.setCurrentPage is what changes pages while testing. Instead, you should check the return value of the function that should return the next page against the value for Page.nextpage.getUrl(); it should return the same value.