title: More Matchers recorded than the expected - Easymock fails from Maven and not from Eclipse
body: <p>I'm having a strange problem with Easymock 3.0 and JUnit 4.8.2.
  The problem only occurs when executing the tests from Maven and not from Eclipse.</p>
  
  <p>This is the unit test (very simple):</p>
  
  <pre><code>...
  protected ValueExtractorRetriever mockedRetriever;
  ...
  
  @Before
  public void before() {
      mockedRetriever = createStrictMock(ValueExtractorRetriever.class);
  }
  
  @After
  public void after() {
      reset(mockedRetriever);
  }
  
  @Test
  public void testNullValueExtractor() { 
      expect(mockedRetriever.retrieve("PROP")).andReturn(null).once();
      replay(mockedRetriever);
  
      ValueExtractor retriever = mockedRetriever.retrieve("PROP");
      assertNull(retriever);
  
      assertTrue(true);
  }
  </code></pre>
  
  <p>And I get:</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: 1 matchers expected, 2 recorded.</p>
  </blockquote>
  
  <p>The weird thing is that I'm not even using an argument matcher. And that is the only method of the test! and to make it even worst it works from Eclipse and fails from Maven!</p>
  
  <p>I found a few links which didn't provide me with an answer:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/2293577/during-suite-tests-easymock-says-0-matchers-expected-1-recorded">Another StackOverflow post</a></li>
  <li><a href="http://www.flyingtomoon.com/2011/04/unclosed-record-state-problem-in.html" rel="nofollow noreferrer">Expected Exceptions in JUnit</a></li>
  </ul>
  
  <p>If I change the unit test and add one more method (which does use an argument matcher):</p>
  
  <pre><code>@Test
  public void testIsBeforeDateOk() {
      expect(mockedRetriever.retrieve((String)anyObject())).andReturn(new PofExtractor()).anyTimes();
      replay(this.mockedRetriever);
  
      FilterBuilder fb = new FilterBuilder();
      assertNotNull(fb);
  
      CriteriaFilter cf = new CriteriaFilter();
      assertNotNull(cf);
      cf.getValues().add("2010-12-29T14:45:23");
      cf.setType(CriteriaType.DATE);
      cf.setClause(Clause.IS_BEFORE_THE_DATE);
  
      CriteriaQueryClause clause = CriteriaQueryClause.fromValue(cf.getClause());
      assertNotNull(clause);
      assertEquals(CriteriaQueryClause.IS_BEFORE_THE_DATE, clause);
  
      clause.buildFilter(fb, cf, mockedRetriever);
      assertNotNull(fb);
  
      Filter[] filters = fb.getFilters();
      assertNotNull(filters);
      assertEquals(filters.length, 1);
  
      verify(mockedRetriever);
  
      logger.info("OK");
  }
  </code></pre>
  
  <p>this last method passes the test but not the other one. How is this possible!?!?!</p>
  
  <p>Regards,
  Nico</p>
  
  <p>More links:</p>
  
  <p>"bartling.blogspot.com/2009/11/using-argument-matchers-in-easymock-and.html"</p>
  
  <p>"www.springone2gx.com/blog/scott_leberknight/2008/09/the_n_matchers_expected_m_recorded_problem_in_easymock"</p>
  
  <p>"stackoverflow.com/questions/4605997/3-matchers-expected-4-recorded"</p>