You need to sign in to do that
Don't have an account?
Abdul Mujeeb Shaik
How To Receive URL parameter(s) in test class
Hi One Vf page And Controller Through Which am passing 2 datefields as parameters to another Vf page.
In test class i want to Pass it to cover the test class.
For this Code i wnat Test logic .
But still 'MyVariable1' & 'MyVariable2' is not passing pls help me its uregent to deployee
Thanks
In test class i want to Pass it to cover the test class.
For this Code i wnat Test logic .
if((Apexpages.currentPage().getParameters().get('MyVariable1'))!=NULL) fDate = (Date.valueOf(Apexpages.currentPage().getParameters().get('MyVariable1'))); else fDate=date.valueof('2014-01-01'); if((Apexpages.currentPage().getParameters().get('MyVariable2'))!=NULL) tDate = (Date.valueOf(Apexpages.currentPage().getParameters().get('MyVariable2'))); else tDate=date.valueof('2014-6-30');
This is how i worte the test class for this
PageReference pageRef = Page.effortsbymonthtilldateinexcelv1; Test.setCurrentPage(pageRef); EffortsByMonthTillDateinExcelv1 controller1 = new EffortsByMonthTillDateinExcelv1 (); //System.currentPageReference().getParameters().put('MyVariable1', '2014-01-01'); //System.currentPageReference().getParameters().put('MyVariable2', '2014-12-31'); ApexPages.currentPage().getParameters().put('MyVariable1', '2014-01-01'); ApexPages.currentPage().getParameters().put('MyVariable2', '2014-12-31'); EffortsByMonthTillDatev1 ef1= new EffortsByMonthTillDatev1 (); ef1.fDate = date.valueof('2014-01-01'); ef1.tDate = date.valueof('2013-01-01'); ef1.mainlogic(); ef1.search(); ef1.getHeadcountList(); ef1.appendEmptyOpportunities(); ef1.createHeadCountPerMonth();
But still 'MyVariable1' & 'MyVariable2' is not passing pls help me its uregent to deployee
Thanks
Best Answer chosen by Abdul Mujeeb Shaik
James Loghry
Looks like you're really close. Try the following instead, as I don't think ApexPages.currentPage() will reference what you're expecting in the unit test.