title: EasyMock : java.lang.IllegalStateException: 1 matchers expected, 2 recorded
body: <p>I am having a problem with EasyMock 2.5.2 and JUnit 4.8.2 (running through Eclipse). I have read all the similar posts here but have not found an answer. I have a class containing two tests which test the same method. I am using matchers.</p>
  
  <ol>
  <li>Each test passes when run alone.</li>
  <li>The first test always passes - this is true if I switch the order of the tests in the file.</li>
  </ol>
  
  <p>Here is a simplified version of the test code:   </p>
  
  <pre><code>private Xthing mockXthing;
  private MainThing mainThing;
  
  @Before
  public void setUp() {
      mockXthing = EasyMock.createMock(Xthing.class);
      mainThing = new MainThing();
      mainThing.setxThing(mockXthing);
  }
  
  @After
  public void cleanUp() {
      EasyMock.reset(mockXthing);
  }
  
  @Test
  public void testTwo() {
      String abc = "abc";
      EasyMock.expect(mockXthing.doXthing((String) EasyMock.anyObject())).andReturn(abc);
      EasyMock.replay(mockXthing);
      String testResult = mainThing.testCallingXthing((Long) EasyMock.anyObject());
      assertEquals("abc", testResult);
      EasyMock.verify(mockXthing);
  }
  
  @Test
  public void testOne() {
      String xyz = "xyz";
      EasyMock.expect(mockXthing.doXthing((String) EasyMock.anyObject())).andReturn(xyz);
      EasyMock.replay(mockXthing);
      String testResult = mainThing.testCallingXthing((Long) EasyMock.anyObject());
      assertEquals("xyz", testResult);
      EasyMock.verify(mockXthing);
  }
  </code></pre>
  
  <p>The second (or last) test always fails with the following error:</p>
  
  <pre><code>java.lang.IllegalStateException: 1 matchers expected, 2 recorded
  </code></pre>
  
  <p>Any insight to this would be greatly appreciated.</p>
  
  <p>Thanks,
  Anne</p>