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

Writing Test Class
Hi Gurus,
I have writen a very short apex code to be able redirect from one Visualforce page to another however, I now have to write a test class, which i am awful at :D
So it would be great if someone could please assist me :)
This is my short apex code for the redirection:
If someone know how I could write the test then please let me know! Thanks!!
I have writen a very short apex code to be able redirect from one Visualforce page to another however, I now have to write a test class, which i am awful at :D
So it would be great if someone could please assist me :)
This is my short apex code for the redirection:
public with sharing class CustomerSatisfaction { public String currentRecordId {get;set;} public CustomerSatisfaction (ApexPages.StandardController controller) { this.currentRecordId = ApexPages.CurrentPage().getparameters().get('id');} public PageReference UK_Flag () { PageReference pageref = new PageReference('/apex/CustomerSatisfaction_EN?Id='+currentRecordId); pageref.setRedirect(true); return pageref;} public PageReference France_Flag () { PageReference pageref = new PageReference('/apex/CustomerSatisfaction_FR?Id='+currentRecordId); pageref.setRedirect(true); return pageref;} }
If someone know how I could write the test then please let me know! Thanks!!
All Answers
Try below code.
Note: you need to check null for currentRecordId value in your apex class's page reference methods. Otherwise you will get invalied redirect(page reference)
Best Regards
Sampath
lovely thanks!
@Sampath Suranji, the first reply worked so i didnt get a chance to try yours unfortunately , thanks though!