title: Mocking static class with powermockito
body: <p>Even though I followed the <a href="https://code.google.com/p/powermock/wiki/MockitoUsage13" rel="nofollow">manual</a> I cannot seem to mock a static method with PowerMock. I'm trying to mock a singleton god class.</p>
  
  <p>The test code is as follows:</p>
  
  <pre><code>@RunWith(PowerMockRunner.class)
  @PrepareForTest(GodClass.class)
  public class SomeTestCases {
      @Test
      public void someTest() {
           PowerMockito.mockStatic(GodClass.class);
           GodClass mockGod = mock(GodClass.class);
           when(GodClass.getInstance()).thenReturn(mockGod);
           // Some more things mostly like:
           when(mockGod.getSomethingElse()).thenReturn(mockSE);
  
           // Also tried: but doesn't work either
           // when(GodClass.getInstance().getSomethingElse()).thenReturn(mockSE);
  
           Testee testee = new Testee(); // Class under test
      }
  }
  </code></pre>
  
  <p>And Testee:</p>
  
  <pre><code>class Testee {
       public Testee() {
      GodClass instance = GodClass.getInstance();
      Compoment comp = instance.getSomethingElse();
       }
  }
  </code></pre>
  
  <p>However, this doesn't working. Debugging mode shows that <code>instance</code> is <code>null</code>. What must be done different?</p>
  
  <p>(Yes, I know the code is horrible but it's legacy and we want to have some unit tests before refactoring)</p>