« Return to Thread: Mocking Database Access - unexpected invocation

Re: Mocking Database Access - unexpected invocation

by Nat Pryce :: Rate this Message:

Reply to Author | View in Thread

2009/7/1 Winfried <w.kurtz@...>:
> The problem now is that i get an unexpected invocation when i run this test.
> I asume that's becaus jmock expects a call with the the object instantiated
> in the test as parameter but gets a new object. Is this correct?

Yes, that's why you're getting the failure.

>  Is there any way avoiding to use the same object?

You need to either pass the objects that the DBGroup needs into the
service, or loosen the constraints on the parameters to the mocked
calls.

For example, the service can be given the TransactionManager when it
was created (e.g. pass the TransactionManager to its constructor).
Then your test can mock out the TransactionManager and the Transaction
it creates, and that transaction can be used in expectations on the
DBGroup and DBUser.

--Nat

--
http://www.natpryce.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Mocking Database Access - unexpected invocation