Vivek R | 26 Aug 07:56
Picon

Mocking Objects

Hi,

Pardon me for a not so great subject :). Anyways, my question follows:

Consider src file X.java

Y obj1;
Z obj2 = Y.f();
obj2.g();

Consider the mocking file XMock.java
I am creating 2 mock objects

mock1 = mock object of class Y
mock2 = mock object of class Z;

/* Now, for the code :) */
one(mock1).f();will(returnValue(mock2));
one(mock2).g();

Q: Is this ok ? It throws an exception saying "forgot to mention an expectation?" on the line "obj2.g()" (in X.java)

Thanks
Vivek


Gmane