You need to sign in to do that
Don't have an account?
NikiG22
Help on a Controller Test
I have a page redirect/Save controller and need help wrighting a test class for it. I have 19% covered right now and need 100%
Any help would be appriciated
Niki
Controller and Test:
public class mywebLeadController { Lead lead; public Lead getLead() { if(lead == null) lead = new Lead(); return lead; } public PageReference savelead() { // Add the lead to the database. insert lead; // Send the user to the landing page for the new lead. PageReference leadPage = page.WebLeadLandingPage; leadPage.setRedirect(true); return leadPage; } @IsTest static void testSave() { Lead lead = new Lead (); mywebLeadController pjae = new mywebLeadController (); Lead.FirstName = 'Test'; Lead.LastName = 'Test'; Lead.Company = 'OTJ - NG'; Lead.Email = 'test@otj.com'; insert lead; PageReference leadPage = page.WebLeadLandingPage; leadPage.setRedirect(true); System.debug('the current page is...' +ApexPages.currentPage() ); }
}//End
use "getLead" and "savelead" method
but, "lead" data isn't editable in mywebLeadController...
Awesome! thank you so much for your help
Final Code:
when i try to deploy the final code i get the following error?
Any ideas?
oh... sorry, i mistake
line 37:
System.assertEquals(leadPage.getURL(), pjae.savelead().getURL());