title: Verify that a private method was NOT executed JMockit
body: <p>I have looked around for this question a bit and have not found exactly what I need. I have learned a bit more about JMockit and mocking. Which is good. Seems like everyone wants to know how to make sure something has executed. I would like to learn the opposite.</p>
  
  <p>Ok - I am writing a test to check a not so happy path in a public method. The method that is being tested is <code>void</code> so I can't really <code>assert</code> the results. <strong>What I would like to do is verify that a method was NOT executed in this test case.</strong></p>
  
  <p>For example:</p>
  
  <pre><code>class ClassToTest {
    private void method(String arg){}
  
    public void publicMethod(String arg0, String arg1){
      if(false){
        //this method should never get called.
        method(arg0);
      }
    }
  }
  
  class TestingClass{
    @Tested
    private ClassToTest classToTest = new ClassToTest();
  
    @Test
    public void testCheckingIfPrivateMethodWasCalled(){
      classToTest.publicMethod("string1", "string2");
  
      new Verifications() {
        {
          //At this point I am trying something like
          Deencapsulation.invoke(classToTest, "method", "string1");
          times = 0; //Also tried maxTimes = 0;
          //Through debug it looks like the invoke is doing what it's named...
          //invoking the private method, I don't want to invoke.
          //How do I check that ClassToTest#method was not called?
        }
      }
    }
  }
  </code></pre>
  
  <p>What I am getting as results for the test case is a <code>java.lang.IllegalStateException: Missing invocation to mocked type at this point; please make sure such invocations appear only after the declaration of a suitable mock field or parameter</code>. Which is on the line of <code>times = 0;</code>.</p>
  
  <p>I know the <code>invoke</code> is executing the private method. I am left scratching my head trying to figure out how to "check" that said method is called with out invoking/executing it.</p>
  
  <p>Thanks.</p>