4

I need to test a method in Developer console .

  1. Method is public . So I can test from Dev Console , right?
  2. Since it's a static method , I need to call ClassName.Methodname(Parameters)- This class should be the outermost class or the inner one?
  3. Method signature is public static List<InnerClassName> methodname(List<String> RecorIds) - Can you please give an example of parameter?

I was calling like:

OuterClassName.methodname(id1,id2); 

Can anyone please correct me?

3
  • I'm sure you are not passing two parameters instead of one.are you?? Commented May 13, 2016 at 10:52
  • My question would be - How do I pass the List<string> as parameter to test this out? Commented May 13, 2016 at 10:54
  • 2
    List<String> RecordIds =new List<String>(); recordIds.add(id1); recordIds.add(id2); OuterClassName.methodname(recordIds); Commented May 13, 2016 at 10:58

2 Answers 2

3
List<InnerClassName> innerclassList = new List<InnerClassName>(); List<String> strList = new List<String>(); strList.add(id1); strList.add(id2); innerclassList =OuterClassName.methodname(strList ); 

hope this will help..

5

Apex has neat collection initialization syntax (for arrays, lists, sets and maps) that allows less verbose code:

innerclassList = OuterClassName.methodname(new List<String>{id1, id2}); 

Better to use the Id type rather than the String type to make what is going on clearer; using the Id type also makes some useful methods available.

So the call could be:

innerclassList = OuterClassName.methodname(new Id[]{id1, id2}); 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.