title: jMock Mocking Classes and Interface
body: <p>I was experimenting jMock as my mocking framework for my project. I came into a situation where I need to mock both a class and an interface. I used the <code>ClassImposteriser.INSTANCE</code> to initiate the impostor of the context.</p>
  <p>Supposing a class <code>Validator</code> and an interface <code>Person</code> to mock. When I was going to mock the Interface <code>Person</code>, I ran to a problem <code>NoClassFoundDefError</code>. When I mocked the class <code>Validator</code>, there was no problem.</p>
  <p>I need both that class and interface but I can't solve the problem.
  Please HELP.</p>
  <p>Code Example:</p>
  <p>Mockery</p>
  <blockquote>
  <p><code>private Mockery context = new JUnit4Mockery() {{ setImposteriser(ClassImposteriser.Class) }};</code></p>
  </blockquote>
  <p>Class :</p>
  <blockquote>
  <p><code>private Validator validator;</code></p>
  </blockquote>
  <p>Interface :</p>
  <blockquote>
  <p><code>private Person person;</code></p>
  </blockquote>
  <p>Inside Test Method</p>
  <blockquote>
  <p><code>validator = context.Mock(Validator.class);</code> ----&gt; Working</p>
  <p><code>person = context.Mock(Person.class);</code> ----&gt; <code>NoClassFoundDefError </code></p>
  </blockquote>