Java Mailing List Archive

http://www.gg3721.com/

Home » user.groovy »

[groovy-user] Mock objects and meta class issues

Peter Ledbrook

2008-08-01

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi,

In playing around with mock objects, I've come across this issue which
I don't know how to solve. I start with a mock object that is created
like this:

def mock = [:] as MyService

I then implement expectations by adding methods via the meta class:

MyService.metaClass.doSomething = {...}

The problem is that if a MyService method, that I haven't overridden
via the metaClass, is called on the mock object, the real MyService
method is invoked. I would much prefer the call to throw an error if
the method hasn't been added to the expectations (i.e. "unexpected
method call").

Does anyone know how to do this? Is it even possible?

Thanks,

Peter

--
Software Engineer
G2One, Inc.
http://www.g2one.com/

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

  http://xircles.codehaus.org/manage_email


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