You need to sign in to do that
Don't have an account?
Test controller getting compile errors
Hello, I have a controller creditProcess2 I created for a three column data table for date/time stamped custom fields. The controller has compiled in the sandbox and I am creating the test controller. Here is my code for the test controller:
public class thecreditProcess2Test{ public static testMethod void testcreditProcess2 () { pageReference PageRef = Page.success; Test.setcurrentPage(PageRef); creditProcess2 controller = new creditProcess2(); String nextPage=save.creditProcess2().get.URL(); //no parameters and page will fail System.assertEquals ('/apex/failure?error = noParam., nextPage'); ApexPages.currentPage().get.Parameters().put('qp', 'yyyy'); //enter in test values for the System.Assert creditProcess2 = new creditProcess2(); creditProcess2.setLastName('lastname'); creditProcess2.setFirstName('firstname'); creditProcess2.setCompany('acme'); creditProcess2.setEmail('firstlast@acme.com'); nextPage = creditProcess2.save().getUrl(); //success for new page parameters System.assertEquals('/apex/success', nextPage); //query for test values Lead[] leads = [select id, email from lead where Company = 'acme']; System.assertEquals('firstlast@acme.com', leads[0].email); } }
When I compile it I get:
Compile Error: Invalid type: thecreditProcess2 at line 5 column 44
Line 5 is the following: creditProcess2 controller = new creditProcess2();
I have tried other values for the controller name but nothing seems to be getting past the compile error. Any suggestions? I can include the original controller if needed.
Thanks,
Hey
Please post the controller too.
Wes
Wes,
here is my original controller. I don't have the SOQL query fully populated because I created the lead custom fields in production but they are not in the sandbox.
thanks
Try out this sample test code given below :
@isTest
private class thecreditProcess2Test
{
static testMethod void testcreditProcess2()
{
Lead l = new Lead();
ld.firstname= 'testdata';
ld.lastname= 'testlastdata';
ld.company='acme';
ld.Start_Date__c = Date.newInstance(2009,1,25);
ld.End_Date__c = Date.newInstance(2009,1,30);
insert ld;
Id id = ApexPages.currentPage().getParameters().put('Id',controller.Id);
creditProcess2 controller = new creditProcess2();
PageReference pr = controller.save();
}
}
Hope this helps.
The test class you've posted and the error message you're getting don't really tie up. It's complaining that you're trying to use a class called "thecreditProcess2" but that's not the case. Did you change the test code before posting?
Wes
Thanks Pradeep,
I will give it a shot.
Wes,
should I change the test values in the controller? Forgive my ignorance, this is the first time I have done this.