Java Mailing List Archive

http://www.gg3721.com/

Home » user.jmock »

[jmock-user] Mocking Objects

Vivek

2008-08-26

Replies: Find Java Web Hosting

Author LoginPost Reply
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

©2008 gg3721.com - Jax Systems, LLC, U.S.A.