Java Mailing List Archive

http://www.gg3721.com/

Home » user.jmock »

[jmock-user] how to test property of argument passed to method?

limbicsystem

2008-10-01

Replies: Find Java Web Hosting

Author LoginPost Reply
What is the proper way to test a property of an argument passed into a method of a mock, under JMock 2.5?

Let's say that my CUT would normally be called like:

   myObject.myMethod(arg);

and I'd like to verify that "arg" is of a particular type, and that it has a particular property set.  I'm trying to do this:

   one(mock).myMethod(with(hasProperty("prop", eq("value"))));

but hasProperty() returns Object, while myMethod() is expecting type Argument.

I *can* do the following, which works:

   one(mock).myMethod(with(any(Argument.class)));

I've been googling this problem for 2 days now, so any help would be greatly appreciated, thanks.

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