title: How do I mock a method with void return type in JMockit?
body: <p>I'm using TestNG and JMockit for testing. My code goes like this:</p>
  
  <pre><code>public boolean testMethod(String a, String b) {
     //processing .....
     mockClass.mockMethod(a);
     //processing....
  }
  </code></pre>
  
  <p>The mockMethod():</p>
  
  <pre><code>Class MockClass {
       public void mockMethod(String a) {
          //some operations to mock
       }
   }
  </code></pre>
  
  <p>I'm using MockUp according to this question: (<a href="https://stackoverflow.com/questions/24112799/how-to-mock-public-void-method-using-jmockit">How to mock public void method using jmockit?</a>) </p>
  
  <p>I'm still getting the NPE. What am I doing wrong? Also, is it because I'm using it like this?</p>
  
  <pre><code>@Test
  public void test() {
     new Expectations() {
         {
         //for statements preceding mockMethod()....
         new MockUp&lt;MockClass&gt;(){
             @Mock
             public void mockMethod(String a) {
                 //do nothing
             }
         };
         }
     };
   }
  </code></pre>
  
  <p>I've put it outside Expectations() &amp; used NonStrictExpectations too. How do I fix this?</p>