Menu

#3 Add match() to new DynaMock API

open
nobody
None
5
2003-05-16
2003-05-16
No

Here's the use case for a new match():

I have in my code a call to queueConnection.close()
(for example). I use a Mock for QueueConnection. If I
*don't* define either an expect*() or a match*(), I get:

junit.framework.AssertionFailedError:
mockQueueConnection: Unexpected call: close()
Expected no methods
at com.mockobjects.dynamic.Mock.invoke
(Mock.java:95)
[...]

Which means to me that we have to define the
behaviour for any method called (and that there is no
default behaviour assumed). Fine with me. Then, I don't
want to set an expectation on close() because this
mock setup is part of a general setup that I want to
reuse across several tests and some tests do call close
(), some do not.

But there is no match() method.

Basically I'd like to simply tell DynaMock that I don't
care about this close() method. ATM, I've tricked it, by
using:

mockQueueConnection.matchAndReturn("close",
null);

But that seems like a hack (or even a DynaMock bug)
to me.

Thanks
-Vincent

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.