I am fairly new to both unit testing and apex. I am trying to test a method within a class, but i keep getting an error which tells me method does not exist. I have a feeling that perhaps my syntax is incorrect, but in my previous test that i have created where I am doing something very similar. The syntax does in fact work properly which is where I am confused.

In my model ApplicationContactMappingSettingModel I have a the public method:

public List<FieldMap> getFieldMap(String category){
//code to throw exception in here

In my test class

static testMethod void test_get_field_map(){
   Application_Contact_Mapping_Settings__c acmSetting = ApplicationMappingTestDataUtils.createOneApplicationContactMappingSetting('string in here', true, 'another string');
ApplicationContactMappingSettingsModel scmSettingsModel = new ApplicationContactMappingSettingsModel();

When I try to get the public List from my class by writing this:

//in my model the class of FieldMap has these operators
scmSettingsModel.FieldMap('string','another string', 'another string')

List<FieldMap> category = scmSettingsModel.getFieldMap();

I get the error message telling me the method does not exist Does anyone know the proper way of calling this method? Please let me know if there is more information i can add to make this more helpful, Thanks.

1 Answer 1


You declare the method like this:

public List<FieldMap> getFieldMap(String category)

But you use it like this:

List<FieldMap> category = scmSettingsModel.getFieldMap();

Note that the method signatures do not match: the method accepts a string but you did not pass one in.

  • Hi, Thank you for your response. I'm not sure I follow...I must first declare the method within my test and then use it, but I must also supply a string within the ()?
    – user7167
    Commented Mar 4, 2014 at 19:18
  • 1
    Yes, you need to pass a string into the method. When the Apex compiler runs, it will see you gave it a string and find the correct method, and that error should go away. Right now it is looking for a method by the same name that accepts zero parameters, but cannot find it, which is why it gives you that error. This is called method overloading and works like most other modern languages such as Java, C#, and C++.
    – user6861
    Commented Mar 4, 2014 at 19:20
  • Thanks for clarifying, when i do this i get the error "Invalid type: FieldMap" Is there a special way to be calling a list that has a class in it?
    – user7167
    Commented Mar 4, 2014 at 19:23
  • That is the correct way, as long as FieldMap is a valid class. It must be, if the ApplicationContactMappingSettingModel class compiles.
    – user6861
    Commented Mar 4, 2014 at 19:32
  • 1
    The inner class would be called ApplicationContactMappingSettingsModel.FieldMap. Commented Mar 5, 2014 at 0:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .