title: Is there any difference between ".andReturn(...).anyTimes()" and ".andStubReturn(...)" in EasyMock?
body: <p><a href="https://stackoverflow.com/questions/3740376/easymock-andreturn-vs-andstubreturn">This post</a> suggests both- that there is a difference (see comment by user SnoopyMe) and that the two can be used interchangeably. The EasyMock documentation makes no mention of any difference.</p>
  
  <p>Is there any difference, either practically or semantically? If so, when is it more appropriate to use one over the other? </p>
  
  <p>EDIT:</p>
  
  <p>The following test suggests that there is a difference, at least when used with a strict mock:</p>
  
  <pre><code>@Test
  public void testTestMe() {
      Bar bar = createStrictMock(Bar.class);
      expect(bar.doBar()).andReturn(1).anyTimes();
      expect(bar.doOtherBar()).andReturn(2).once();
      replay(bar);
  
      Foo foo = new Foo(bar);
      foo.testMe();
      verify(bar);
  }
  
  @Test
  public void testTestMeAgain() {
      Bar bar = createStrictMock(Bar.class);
      expect(bar.doBar()).andStubReturn(1);
      expect(bar.doOtherBar()).andReturn(2).once();
      replay(bar);
  
      Foo foo = new Foo(bar);
      foo.testMe();
      verify(bar);
  }
  
  public class Foo {
      private final Bar _bar;
      public Foo(Bar bar) {
          _bar = bar;
      }
  
      public void testMe() {
          _bar.doBar();
          _bar.doOtherBar();
          _bar.doBar();
      }
  }
  </code></pre>
  
  <p>andReturn(...).anyTimes() still verifies order, which is enforced by the strict mock on verification. andStubReturn(...), however, does not.</p>
  
  <p>However, it's still not clear to me if this is the only difference, or what the semantic difference is. For example, is anyTimes() the same as stubReturn() for a regular (not strict) mock?</p>