title: Mockito stubbing outside of the test method
body: <p>I have the following method outside the test method </p>
  
  <pre><code>private DynamicBuild getSkippedBuild() {
      DynamicBuild build = mock(DynamicBuild.class);
      when(build.isSkipped()).thenReturn(true);
      return build;
  }
  </code></pre>
  
  <p>but when I call this method I get the following error </p>
  
  <pre><code>org.mockito.exceptions.misusing.UnfinishedStubbingException: 
  Unfinished stubbing detected here:
  -&gt; at LINE BEING CALLED FROM
  
  E.g. thenReturn() may be missing.
  Examples of correct stubbing:
      when(mock.isOk()).thenReturn(true);
      when(mock.isOk()).thenThrow(exception);
      doThrow(exception).when(mock).someVoidMethod();
  Hints:
   1. missing thenReturn()
   2. you are trying to stub a final method, you naughty developer!
  </code></pre>
  
  <p>Looks like mockito is not happy when you stub outside the test method. Is that not supported ?</p>
  
  <p>EDIT: I can get this to work by doing the stubbing in <code>@Test</code> method but I want to reuse the stubbing across <code>@Test</code>s.</p>