Mocking Objects

View: New views
8 Messages — Rating Filter:   Alert me  

Mocking Objects

by ravisankarvivek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 Objects

by eraonel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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


Re: Mocking Objects

by ravisankarvivek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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



RE: Mocking Objects

by eraonel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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



Re: Mocking Objects

by ravisankarvivek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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:53Subject: 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




Re: Mocking Objects

by nat_pryce :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I 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 Objects

by eraonel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry 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:
Then as Nat said. What code are you testing?
 
cheers,
 
//mike


From: Vivek R [mailto:vivmbbs@...]
Sent: den 26 augusti 2008 09:53 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




Re: Mocking Objects

by ravisankarvivek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Cool :)

Vivek

On Tue, Aug 26, 2008 at 9:54 PM, Mikael Petterson <mikael.petterson@...> wrote:
Sorry 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:
Then as Nat said. What code are you testing?
 
cheers,
 
//mike


From: Vivek R [mailto:vivmbbs@...]
Sent: den 26 augusti 2008 09:53 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




LightInTheBox - Buy quality products at wholesale price!