In EasyMock 1.x you could use setDefaultReturnValue() to stub a default return value for a method call but you could also change the default return value by simply calling setDefaultReturnValue() again, with a new value. We have over 20000 tests and a significant number of these make use of this "feature". Notably, in a call to reset, we often reset the default return value for various state machines, but from time to time we may need to state to be different at the start of a test. We achieve this by then setting then default value for the same method call with a new value. From EasyMock 2.x onwards, this is no longer possible to set the default return value/stubbed return value multiple times with different values between calls to reset.
I had a look at the source for 2.5.2 specifically and noticed that the MocksBehaviour.addStub() does not look for an existing expected invocation before adding a new invocation and result object. This in itself is not wrong, but the MocksBehaviour.getStubResult() is iterating through the list of stubbed values and returning as soon as it finds the first one! This would seem to indicate that there should be only one stubbed value per mock method call.
I offer the attached SVN patch file for your consideration that will enable MocksBehaviour.addStub() to determine if an existing invocation and result exists and replace the stubbed result if applicable. This would re-enable the 1.x functionality and eliminate the ability to add multiple redundant stubbed values.
EM252 MocksBehaviour.addStub() Patch
Need 1.0 backward compatability, so if the patch is accepted would need this patched in Easymock 2.5.x
EM300 MocksBehaviour.addStub() Patch