How to tell gomock to ignore arguments?

3,755 views
Skip to first unread message

rvenu...@gmail.com

unread,
Feb 4, 2014, 9:17:39 AM2/4/14
to golan...@googlegroups.com
Hi All

I have a question about gomock.  How do I make the EXPECT ignore the exact parameters passed.
For e.g., to mock an interface which takes an int and returns a string, I can use


mockObj.EXPECT().SomeMethod(1).Return("This is return value")

However, this is setting the expectation for 1 as the parameters, not any int. I am asking as this is a common enough feature in other programming language tools. For e.g., http://rickgaribay.net/archive/2009/06/12/rhino-mocks-ignore-arguments.aspx

Thanks
-Rao




David Symonds

unread,
Feb 4, 2014, 8:47:55 PM2/4/14
to rvenu...@gmail.com, golang-nuts
Pass gomock.Any() instead of 1.

rvenu...@gmail.com

unread,
Feb 5, 2014, 3:03:45 AM2/5/14
to golan...@googlegroups.com, rvenu...@gmail.com
Thanks.  That worked
Reply all
Reply to author
Forward
0 new messages