You need to sign in to do that
Don't have an account?

Test Coverage
Hi,
I am trying to create a testMethod for test coverage of a functionality. Test method name cannot have parameters. How do we call a method which has parameters inside this test method?
Example:
static testMethod void testgenerateActivityForSuspendedBill() {
createCurrentDS(dsList, date.newInstance(2007, 10, 01), date.newInstance(2007, 10, 31), '(111) 555-5555') ;
}
Severity and Description Path Resource Location Creation Time Id
Save error: Method does not exist or incorrect signature: createCurrentDS(LIST:SOBJECT:DeviceService__c, Date, Date, String) DMPortal2_Apex_Staging/src/unpackaged/classes ActivityService.cls line 151 1226525337544 22864
What is the mistake I am doing?
Quick help would be appreciated.
thanks,
kathyani
I am trying to create a testMethod for test coverage of a functionality. Test method name cannot have parameters. How do we call a method which has parameters inside this test method?
Example:
static testMethod void testgenerateActivityForSuspendedBill() {
createCurrentDS(dsList, date.newInstance(2007, 10, 01), date.newInstance(2007, 10, 31), '(111) 555-5555') ;
}
Severity and Description Path Resource Location Creation Time Id
Save error: Method does not exist or incorrect signature: createCurrentDS(LIST:SOBJECT:DeviceService__c, Date, Date, String) DMPortal2_Apex_Staging/src/unpackaged/classes ActivityService.cls line 151 1226525337544 22864
What is the mistake I am doing?
Quick help would be appreciated.
thanks,
kathyani
Here is a simple example:
and the supporting test class:
You can create all of your data in the testmethod and instantiate the methods within th testmethod or perform DML which invokes the corresponding trigger logic.
public DeviceService__c createCurrentDS(List<DeviceService__c> dsList, Date billStartDate, Date billEndDate, String billServiceNumber) {
}
DeviceService__c d = createCurrentDS(dsList, date.newInstance(2007, 10, 01), date.newInstance(2007, 10, 31), '(111) 555-5555') ;
}
What you're missing is the red-highlighted code above, in which you instantiate your class. Since createCurrentDS() is not a static method, it can only be called on an instance of the class.
if your method is not static then in the test method add the following:
YOURCLASSNAME sample = new YOURCLASSNAME();
List<ServiceService__c> dsList = new List<ServiceService__c>();
//populate your list then call the method:
sample.createCurrentDS(dsList, date.newInstance(2007, 10, 01), date.newInstance(2007, 10, 31), '(111) 555-5555') ;
Please review the Apex docs: http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_testing.htm