You need to sign in to do that
Don't have an account?
etechcareers
trying to call a page in testclass but not successfulll????
hi the following is the page reference in my apex controller:
public PageReference step3() { //Contribution RecordType if(rtps=='012S0000000D3Q5IAK'){ return Page.znewopptystep_Contribution; } //Contribution - Special Events RecordType if(rtps=='012S0000000D3QKIA0'){ return Page.znewopptystep_Contribution_SpecialEvents; } return null; }
Here is my test method:
static testMethod void testSaveone() { ZnewOpportunityController ext = new ZnewOpportunityController(); Account acct = ext.getAccount(); acct.name='sss'; acct.Org_Recognition_Name__c='UFC'; acct.Type='Individual'; acct.Relationship_Stage__c='Lead'; acct.BillingState='CT'; acct.BillingStreet='134 Laurel'; acct.BillingCity='Mineola'; acct.BillingPostalCode='11501'; acct.BillingCountry='USA'; acct.ShippingState = 'CT'; acct.ShippingCountry = 'USA'; acct.ShippingPostalCode = '11501'; acct.ShippingCity = 'Mineola'; acct.ShippingStreet = '134 Laurel'; acct.recordtypeid = '012700000005UJ9AAM'; Contact con = ext.getContact(); con.AccountId = acct.Id; con.firstname='jdhjd'; con.lastname='hdjdhdh'; con.email='hello@email.com'; con.phone='5161231234'; con.recordtypeid = '012700000005ITPAA2'; Opportunity opp = ext.getOpportunity(); opp.Name = 'lslsls'; opp.Accountid=acct.id; opp.stageName='Lead'; opp.CloseDate=Date.newinstance(2010,12,31); opp.Acknowledge_Type__c = 'City'; opp.Funding_Source__c = 'Individual'; opp.Public_Private_Funding__c = 'Public'; opp.StageName = 'Prospect'; opp.Reinvestment__c = 'Reinvestment'; opp.FYs_Applied_To__c = 'FY11'; opp.recordtypeid ='012S0000000D3Q5IAK'; PageReference testprA = Page.znewopptystep_Contribution; Test.setCurrentPage(testprA); ext.Step3(); }
Any advice please
Can you tell us what issue you are seeing? I'm guessing that you are getting an error or code unexpectedly not covered, but it would be better if you give us the details.
There is no need in test class to refer any page, it calls automatically on the basis of your condition. For an example PageReference pg = ext.Step3();
Hope this helps.
Yeah I just noticed that... but because I have so many recordtypes.. It seems like for me to get the coverage I would have to do a spearate testmethod for each page I call with a condition? Is that true..
for example:
I am now on ext.saveone();
Test class:
This one works for when opportunity recordtype is Contribution
Do i have to do the same for Grant, In Kind, etc....
Or can I update the recordtype and call the method ext.saveone() again???