title: How can I use Groovy's mock.interceptor package to mock an objects constructor?
body: <p>In my attempt to mock an object in Groovy using the <code>mock.interceptor</code> package:</p>
  
  <pre><code>def mock = new MockFor(TheClass);
  mock.demand.theMethod{ "return" }
  mock.use {
      def underTest = new TheClass()
      println underTest.theMethod()
  }
  </code></pre>
  
  <p>The problem I have is when creating <code>TheClass()</code> in the <code>use{</code> block, it uses the actual constructor which, in this circumstance, I'd rather it not use. How can I create an instance of this class so I can test the method I do care about, <code>theMethod</code>, without needing to use the constructor?</p>
  
  <p>Using EasyMock/CE, mocks can be made without using the constructor, but am curious how to achieve that in Groovy.</p>