2011-06-17

EasyMock’s all-concrete or all-matchers requirement

We've been burned by this while trying to mix easymock expectation with a constant String value.
The way to avoid these problems is to decide not to use EasyMock at all, instead creating your own hand-rolled doubles. And if you decide to use EasyMock in your project, ...

* Make sure at least someone on your team understands how EasyMock works under the hood.
* Be aware of EasyMock’s all-concrete or all-matchers requirement, and that violations of this requirement can be violated by automated refactoring.
* If you use EasyMock matchers, make sure that they are produced while marshalling the arguments to call the mock method, and not beforehand.

No comments: