title: Passing mocked static method to another class
body: <p>I have mocked a static method of a class using Powermock in my test class. The problem I face is that this static method is not called directly in my test class, but in some other class. Here is the skeleton:</p>
  
  <pre><code>@Test public void myTest() { 
      PowerMockito.mockStatic(MyClassWithStaticMethod.class);
      PowerMockito.when(MyClassWithStaticMethod.staticMethod()).thenReturn("...");
      List&lt;String&gt; details = MyHelperClass.getDetails();
      ...
      ...
  }
  </code></pre>
  
  <p>Now MyHelperClass.getDetails calls the method that needs to be mocked as it is dependent upon a service.</p>
  
  <p>MyHelperClass.java</p>
  
  <pre><code>public static List&lt;String&gt; getDetails() {
      ...
      ...
      MyObj obj = MyClassWithStaticMethod.staticMethod(); //This needs to return mocked value
      ...
      ...
  }
  </code></pre>
  
  <p>Is there a way to pass the mocked object to the helper class? PowerMockito.mockStatic returns void, where as PowerMockito.mock doesn't mock the static methods. So I am not able to figure out how to pass the mocked object to the helper class getDetails() method.</p>