If you see this while writing unit test with EasyMock, make sure you didn't forget to call replay().
For example:
MyFirstObject myFirstObject = createMock(MyFirstObject.class);
MyObject my = new MyObject();
expect(myFistObject.myMethod()).andReturn(123).anyTimes();
assertEquals(456, my.myOtherMethod());
may cause this exception, but:
MyFirstObject myFirstObject = createMock(MyFirstObject.class);
MyObject my = new MyObject();
expect(myFirstObject.myMethod()).andReturn(123).anyTimes();
replay(myFistObject);
assertEquals(456, my.myOtherMethod());
does not throw this exception.
No comments:
Post a Comment