Detect expectations being set on a mock that has been Replayed
- Dominant language
- HTML
- Stars
- 832
- Forks
- 303
- Avg merge
- 5h 25m
- Merged PRs (30d)
- 9
Description
I've just come across an issue where a mock had been Replayed already, and was later on having expectations set on it. (It wasn't obvious because it was happening across a couple of methods from some Cucumber tests). EasyMock was just failing because the method call wasn't expected, but it would be very useful if EasyMock could somehow detect that the user was trying to set expectations on the mock when they shouldn't be and give a better error message.
The simplest example of this would be:
```
List list = EasyMock.createMock(List.class);
EasyMock.replay(list);
EasyMock.expect(list.get(EasyMock.eq(0))).andReturn("Hello");
```
In the above, the fact that EasyMock.eq() has been called and the matcher produced has not yet been used means that it could be possible for the list.get() call to deduce that an expectation was trying to be recorded and to state as such in the error message. Obviously if only raw values are used then this becomes difficult if not impossible, but reporting the case in some situations might still be useful on occasion.
Contributor guide
Assessment
This issue has not been assessed yet.