EasyMock andReturn() null return value

easymock, null

Solution

The problem here was that I had not called `replay()` on the mock object after specifying the behavior. For some reason, this caused it to allow some of the expected behaviors, but always return null for when a return value was expected. Remember to call `replay()` before using the mock.

Problem

I have built a mock object using EasyMock, and I'm trying to have the object return another object after a method call. The method call does not cause any exception to be thrown, but it returns null, though I am certain the `andReturn()` call had a non-null argument.

Original source