title: How do I use Powermock's Whitebox.invokeMethod(Object instance, Object... arguments) when my first method parameter is String type?
body: <p>I would like to not explicitly name the method I am invoking in the <code>invokeMethod()</code> arguments. Powermock offers an overloaded <code>invokeMethod()</code> that infers the method based on the parameters passed. </p>
  
  <pre><code>invokeMethod(Object instance, Object... arguments)
  </code></pre>
  
  <p>The problem I am running into is that my first parameter is of type <code>String</code>. This invokes the <code>invokeMethod()</code> with the signature, </p>
  
  <pre><code>invokeMethod(Object instance, String methodToExecute, Object... arguments)
  </code></pre>
  
  <p>Here is a model of the test...</p>
  
  <pre><code>@Test
  public void thisIsATest() throws Exception{
      TheClassBeingTested myClassInstance = new TheClassBeingTested();
      String expected = "60";
      String firstArgument = "123A48"; 
  
      ReturnType returnedTypeValue = Whitebox.invokeMethod(myClassInstance, firstArgument, AnEnum.TypeA);
      String actual = returnedTypeValue.getTestedField();
      assertEquals("Expected should be actual when AnEnum is TypeA", expected, actual);
  }
  </code></pre>
  
  <p>This gives me the error,</p>
  
  <pre><code>org.powermock.reflect.exceptions.MethodNotFoundException: No method found with name '123A48' with parameter types: [ AnEnum ] in class TheClassBeingTested.`
  </code></pre>
  
  <p>I got it to work by changing the first parameter's type to <code>Object</code>, but this feels dirty to me.</p>
  
  <pre><code>@Test
  public void thisIsATest() throws Exception{
      TheClassBeingTested myClassInstance = new TheClassBeingTested();
      String expected = "60";
      Object firstArgument = "123A48"; 
  
      ReturnType returnedTypeValue = Whitebox.invokeMethod(myClassInstance, firstArgument, AnEnum.TypeA);
      String actual = returnedTypeValue.getTestedField();
      assertEquals("Expected should be actual when AnEnum is TypeA", expected, actual);
  }
  </code></pre>
  
  <p>Is there a correct way to pass a <code>String</code> type as the first argument while not hard coding my method name into the <code>invokeMethod()</code> call? I have found nothing in the Powermock documentation or forums addressing this, but it certainly cannot be all that uncommon.</p>