title: TestNG + Mockito + PowerMock - verifyStatic() does not work
body: <p>I am new TestNG and unit-testing in general. I am using TestNG 6.9.6 with Mockito 1.10.19 and PowerMock 1.6.4. I want to verify whether the <code>myMethod()</code> method in <code>MyService</code> class internally calls the static method <code>Util.myStaticMethod</code> with the correct arguments. Since verification of static methods is not natively supported in Mockito, I am using PowerMock along with it. My Test class is shown below:</p>
  
  <pre><code>public class MyTest
  {
      private MyService myService;
  
      @Captor ArgumentCaptor&lt;String&gt; argCaptor;
  
      @BeforeMethod
      public void setup()
      {
          MockitoAnnotations.initMocks( this );
          myService = new MyService();
      }
  
      @Test
      @PrepareForTest(MyService.class)
      public void myTest()
      {
          PowerMockito.mockStatic(Util.class);
          myService.myMethod("arg");
  
          PowerMockito.verifyStatic(10);
          Util.myStaticMethod(anyString());
      }
  }
  </code></pre>
  
  <p>This test is expected to fail, as <code>myMethod</code> calls the static method <code>Util.myStaticMethod()</code> only once. But when i run the test, it always passes, no matter what value i pass to <code>PowerMockito.verifyStatic()</code>. </p>
  
  <p>Also, if I write another test method in this class and then run the test, I get the following error</p>
  
  <pre><code>org.mockito.exceptions.misusing.UnfinishedVerificationException: 
  Missing method call for verify(mock) here:
  -&gt; at mypackage.MyTest.myTest(MyTest.java:21)
  
  Example of correct verification:
      verify(mock).doSomething()
  
  Also, this error might show up because you verify either of: final/private/equals()/hashCode() methods.
  Those methods *cannot* be stubbed/verified.
  Mocking methods declared on non-public parent classes is not supported.
  
      at mypackage.MyTest.myTest.setup(MyTest.java:10)
  
  
  Results :
  
  Failed tests: 
    MyTest.setup:10 UnfinishedVerification 
  Missing method call for ver...
  
  Tests run: 3, Failures: 1, Errors: 0, Skipped: 1
  </code></pre>
  
  <p>It fails at the <code>verifyStatic()</code> method, which makes me think that the verifyStatic() method needs something more that i am not providing. Also, it indicates the total number of tests as 3 whereas in this case I have only two test methods.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p><strong>EDIT :</strong> As suggested, I tried putting <code>MyUtil</code> class in the the <code>@PrepareForTest</code> annotation, it still gives the same error.</p>