0

Method does not exist or incorrect signature: StringArrayTest_Test.generateStringArray() ? the code i have written is

@istest
public class StringArrayTest_Test {

    public static List<string> generateStringArray(Integer n)
    {
        List<String> myArray = new List<String>();
        n=4;
        for(Integer i=0;i<n;i++) 
        {
            myArray.add('Test'+i);
            System.debug(myArray[i]);
        }
        return myArray;
    }
}

in anonymus window im giving as

StringArrayTest_Test.generateStringArray();

can any one help me with this

  • Where are you calling StringArrayTest_Test.generateStringArray() method? Please share your actual class as well. – Mahmood Feb 10 '17 at 14:14
  • This seems to be an issue with the parameterized method. Please check it once or provide the complete code. – cloudy-ritz Feb 10 '17 at 14:21
4

First: Running in Anon window will yield the error

System.TypeException: Cannot call test methods in non-test context

Second The signature of your method is:

public static List<string> generateStringArray(Integer n)

So in order to execute it you need to pass an integer as a parameter

StringArrayTest_Test.generateStringArray(1);
  • 1
    Fastest fingers in the west! – Adrian Larson Feb 10 '17 at 14:25
  • 1
    and in the east as well. :D – Mahmood Feb 10 '17 at 14:27
2

Your generateStringArray method is expecting an integer so that it knows how big of an array to generate. Try this in an anonymous window

StringArrayTest_Test.generateStringArray(10);

I think it might be as simple as that!

2

Your method as defined takes an Integer input. You have provided none.

Change:

StringArrayTest_Test.generateStringArray();

To:

StringArrayTest_Test.generateStringArray(0);

(or any other Integer value);

  • third fastest fingers in the west! :) – John Thompson Feb 10 '17 at 14:27
  • This time. Haha. You can tell which of us has the sportsmanship badge already. :) – Adrian Larson Feb 10 '17 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.