title: Grails : How I do mock other methods of a class under test which might be called internally during testing
body: <p>I am writing a test for methodA() in a service class similar to the one given below.</p>
  
  <pre><code>Class SampleService {
    def methodA(){
       methodB()
    }
  
    def methodB(){
    }
  }
  </code></pre>
  
  <p>When I test methodA(), I need to be able to mock the call to methodB() when testing methodA(). I am using version 2.0.x of grails. In the 1.3.x distributions, I would write a self mock like this </p>
  
  <pre><code>def sampleServiceMock = mockFor(SampleService) 
  sampleServiceMock.demand.methodB { -&gt; } 
  </code></pre>
  
  <p>But this doesn't work in the 2.0.x versions. I was wondering what are the other ways of mocking methodB() when testing methodA() </p>