I have a call to a method in a class as follows:

String key1 = "test1";
String key2 = "test2";

long[] datalr = new long[] {};
datalr = TestClass.callerSub(key1,key2);

The test class is as follows:

public class TestClass {

Public TestClass {

public long[] callerSub(string key1, String key2){

long[] datalr = new long[] {0,0};

datalr[0] = 2;
datalr[1] = 3;

return datalr;


I'm getting the following error in the first class:

Error: Compile Error: Method does not exist or incorrect signature: TestClass.callerSub(String, String) at line 54 column 12    

which is the following line:

datalr = TestClass.callerSub(key1,key2);

The datalr data in the callerSub method is just an example above,

Any idea why?


2 Answers 2


The problem is that you are trying to call the function as if it was a static function, but it is declared as an instance function.
You could fix it by either by changing the function declaration to make it static

public static long[] callerSub(string key1, String key2){

or by changing how you call the function, to use it as an instance method

long[] datalr = new long[] {};
TestClass myTC = new TestClass();
datalr = myTC.callerSub(key1,key2);

I'm assuming your TestClass class has the @isTest annotation and the caller class has not. Only test classes can call other test classes' methods.

Either change your TestClass to a common class or change the caller class to a test class.

You must log in to answer this question.

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