Tuesday, May 19, 2009

fewRemainingStrands.tearOut(); EasyMock.expectLastCall().andReturn(yourHair);

Don't get me wrong, EasyMock absolutely rocks for unit testing.

But I've just burned half an hour with frustration, misled by the most misleading error message I've seen in a long while.

What does the following say to you?

java.lang.IllegalStateException: missing behavior definition for the preceding method call: someMethod(interface someType)

Maybe that you forgot to set an expectation for someMethod(someType)? Yeah that's why I thought too. But that would be too straight-forward. Wouldn't involve the fun of the chase :) Simply setting the apparently missing expectation doesn't resolve the issue. To my deep frustration, just now.

What EasyMock is really trying to tell you here is that you've called IMocksControl.replay() in the wrong place. Too late in the day, to be specific. After you've used one of your mocks in anger.

1 comment: