|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
Mocking ObjectsHi,
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 |
|
|
RE: Mocking ObjectsHi,
Add
the expectation around your code:
mockery.checking(new Expectations() {{one(mock1).f();will(returnValue(mock2)); }});
cheers, //mike From: Vivek R [mailto:vivmbbs@...] Sent: den 26 augusti 2008 07:56 To: user@... Subject: [jmock-user] 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 |
|
|
Re: Mocking ObjectsYes, my code is under that only
On Tue, Aug 26, 2008 at 12:09 PM, Mikael Petterson <mikael.petterson@...> wrote:
|
|
|
RE: Mocking ObjectsThen
as Nat said. What code are you testing?
cheers,
//mike From: Vivek R [mailto:vivmbbs@...] Sent: den 26 augusti 2008 09:53 To: user@... Subject: Re: [jmock-user] Mocking Objects Yes, my code is under that only
On Tue, Aug 26, 2008 at 12:09 PM, Mikael Petterson <mikael.petterson@...>
wrote:
|
|
|
Re: Mocking ObjectsWat did Nat say ?
Thx Vivek On Tue, Aug 26, 2008 at 2:18 PM, Mikael Petterson <mikael.petterson@...> wrote:
|
|
|
Re: Mocking ObjectsI didn't say anything! I think Mikael meant Steve.
--Nat 2008/8/26 Vivek R <vivmbbs@...>: > Wat did Nat say ? > > Thx > Vivek > > On Tue, Aug 26, 2008 at 2:18 PM, Mikael Petterson > <mikael.petterson@...> wrote: >> >> Then as Nat said. What code are you testing? >> >> cheers, >> >> //mike >> ________________________________ >> From: Vivek R [mailto:vivmbbs@...] >> Sent: den 26 augusti 2008 09:53 >> To: user@... >> Subject: Re: [jmock-user] Mocking Objects >> >> Yes, my code is under that only >> >> On Tue, Aug 26, 2008 at 12:09 PM, Mikael Petterson >> <mikael.petterson@...> wrote: >>> >>> Hi, >>> >>> Add the expectation around your code: >>> >>> >>> mockery.checking(new >>> >>> Expectations() {{ >>> >>> one(mock1).f();will(returnValue(mock2)); >>> one(mock2).g(); >>> >>> }}); >>> >>> >>> >>> cheers, >>> >>> //mike >>> >>> ________________________________ >>> From: Vivek R [mailto:vivmbbs@...] >>> Sent: den 26 augusti 2008 07:56 >>> To: user@... >>> Subject: [jmock-user] 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 >>> >> > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
RE: Mocking ObjectsSorry
I meant Steve.
cheers,
//mike From: Vivek R [mailto:vivmbbs@...] Sent: den 26 augusti 2008 13:10 To: user@... Subject: Re: [jmock-user] Mocking Objects Wat did Nat say ?
Thx Vivek On Tue, Aug 26, 2008 at 2:18 PM, Mikael Petterson <mikael.petterson@...>
wrote:
|
|
|
Re: Mocking ObjectsCool :)
Vivek On Tue, Aug 26, 2008 at 9:54 PM, Mikael Petterson <mikael.petterson@...> wrote:
|
| Free Forum Powered by Nabble | Forum Help |