Support for recording arguments

2 views
Skip to first unread message

Julien

unread,
Mar 31, 2009, 8:37:21 AM3/31/09
to gmock-dev
We could record arguments being used in expectation for further
assertion on them using the following syntax:

class Testee {
def service
def method() {
service.foo(param1: "bar", param2: 2)
}
}

def mockService = mock()
mockService.foo(record())
play {
testee.method()
}
assertEquals("bar", recorded(mockService.foo).param1)

Not sure about the syntax. Please comment.

Johnny

unread,
Mar 31, 2009, 8:41:31 AM3/31/09
to gmoc...@googlegroups.com
Why not use 'mockService.foo(param1: "bar", param2: 2)' ?

在 2009-03-31二的 05:37 -0700,Julien写道:

Julien

unread,
Apr 12, 2009, 8:58:12 AM4/12/09
to gmock-dev
The idea here is that we don't necessarly care about the exacts
parameter being passed.

If we can record them we could assert on some of them. We had the
example in one of our test and we worked around it by using:
def recorded
mockService.foo( match { recorded = it } )

...nice

Johnny

unread,
Apr 12, 2009, 9:42:39 AM4/12/09
to gmoc...@googlegroups.com
I am still not sure about this, because I cannot think out a scenario
where this 'record' method works but the 'anything' method and 'match'
method don't.

在 2009-04-12日的 05:58 -0700,Julien写道:

Julien Gagnet

unread,
Apr 12, 2009, 10:07:13 AM4/12/09
to gmoc...@googlegroups.com
You are right. Let's shelve it for the moment.

2009/4/12 Johnny <johnny...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages