title: How to mock a return value of a private method in spock test
body: <p>I want to test a public method in which it calls another private method, I used the following reflection way to get the private method and tried to mock the return value of it, but it didn't work as the test stops at where the private call is. Any suggestions?</p>
  
  <pre><code>Method testMethod = handler.getClass().getDeclaredMethod("test", String.class)
  testMethod.setAccessible(true)
  testMethod.invoke(handler, "test string") &gt;&gt; true
  </code></pre>
  
  <p>The testMethod looks like the following: </p>
  
  <pre><code>private boolean test(String str) {
      return true;
  }
  </code></pre>