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

Page-reference Testing
Help me out with testing this class :
mydoc is attachment type.
i tried this
it isnt coverining pagerefrence.
Controller is much big, but i know how to cover other things.
Thank you
public PageReference Next_FoundationWalls(){ if(myDoc.body != null){ myDoc.parentId = myCustomObject.Id; myDoc.Name='FoundationWalls'; insert myDoc; myDoc.body=null;} pageid=ApexPages.currentPage().getParameters().get('id'); obj.Id=pageid; obj.Basement_Foundation_Walls__c = FoundationWalls; obj.Foundation_Wall_Notes__c=FoundationWallsNotes; update obj; Pagereference ref = new Pagereference('/apex/Floor_drain?id='+pageid); ref.setRedirect(true); return ref; }
mydoc is attachment type.
i tried this
@isTest public class HomeEvaluation_Test { static testMethod void HomeEvaluationtest() { HomeEvaluation__c HE = new HomeEvaluation__c(); HomeEvaluationController HC = new HomeEvaluationController(new ApexPages.StandardController(new HomeEvaluation__c())); String pageid; HE.id= pageid; HC.getItems(); HC.getYesOrNO(); HC.getDucting(); PageReference pageRef = new Pagereference(''/apex/Floor_drain?id='+pageid); Test.setCurrentPage(pageRef); } }
it isnt coverining pagerefrence.
Controller is much big, but i know how to cover other things.
Thank you
You can create instance of the class and the call this pagereference method and before calling this method you can set the page id as
ApexPages.currentPage().getParameters().put('id', obj.Id);
provide the id which should be in page then it will work..
Thanks
Sandeep
You need to call your method as following from Test class.
Thanks,
Himanshu
Himanshu , i tried your solution also , test is getting failed.
Thanks for the help