You need to sign in to do that
Don't have an account?
ckahl
Test Methods
I've never created test methods before and I'm having difficulties understanding the workbooks. Can anyone help me out here? I successfully (or so I think) created one test that works, but I'm stuck on the others....
public class TimeOffRequestFlow { public Flow.Interview.Time_Off_request myFlow { get; set; } public String getmyID() { if (myFlow==null) return ''; else return myFlow.TimeOffRequestID; } public PageReference getOID(){ PageReference p = new PageReference('/' + getmyID()); p.setRedirect(true); return p; } //------------------------- tests -------------------------- @IsTest static void testMyClass(){ ApexPages.currentPage().getParameters().put('id','blablabla'); timeoffrequestflow obj = new timeoffrequestflow(); } }
Try this one.... leaving out the mandatory testMethod has kicked my but many times.
It is mandatory.... matter of fact the entire static testMethod is required on all tests.
//------------------------- tests --------------------------
@IsTest
// static void testMyClass(){
static testMethod void testMyClass() {
ApexPages.currentPage().getParameters().put('id','blablabla');
timeoffrequestflow obj = new timeoffrequestflow();
}
Agreed with Tommy,you are missing testmethod keyword in your method declaration.Apex would not understand if this is a Test Class or now unless you declare with the following syntax.
@(IsTest)
public class flowtest{
static testmethod void myUnitTest(){
// do your coding here
}
}
for more you can check the below link :-
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
try to make a separate class for your tests so that they dont count towards your codebase limits
Here is some info on unit tests
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
Use Test.startTest() to reset governor limits to make a fair test
When you are sending an ID to the page create the record as test data first and pass this ID to the page