Open GoogleCodeExporter opened 9 years ago
I think we still need to discuss the DSL, also the one of nice mock.
I think the perfect DSL would be:
strict mock(Date, constructor("now"))
However, it cannot be used in assignments:
def m = strict mock(Date, constructor("now")) // compilation error
I think the DSL "mock(Date, constructor("now"), strict)" may be our only choice
unless we can find a better one.
Original comment by JohnnyJianHY
on 4 Feb 2009 at 3:19
We can have a think about it. Another solution could be:
def m = strictMock(Date, constructor("now"))
But we couldn't have a nice and strict mock - unless with strictNiceMock...
Original comment by julien.g...@gmail.com
on 4 Feb 2009 at 7:53
I doubt that do we need strict mock while we have got strict closure.
Similarly, we
have stub method but don't have stub mock.
Original comment by JohnnyJianHY
on 4 Feb 2009 at 9:37
I can see some cases where you might want to have strict ordering on a single
object
and having strict mock might be a great shortcut.
We can wait and see...
Original comment by julien.g...@gmail.com
on 4 Feb 2009 at 6:50
OK
Original comment by JohnnyJianHY
on 5 Feb 2009 at 2:41
Maybe we can use decorator pattern here:
def m1 = strict(mock(Date))
def m2 = nice(mock(Date))
def m3 = strict(nice(mock(Date)))
// and maybe we would have stub mock
def m4 = stub(mock(Date))
// or maybe partial mock
def m5 = partial(mock(Date))
// aha, strict partial stub mock
def m6 = strict(partial(stub(mock(Date))))
Original comment by JohnnyJianHY
on 5 Feb 2009 at 4:35
This is probably what's looking nicer (not for the partial stub mock).
What did you have in mind for the partial?
Original comment by julien.g...@gmail.com
on 5 Feb 2009 at 6:48
partial mock:
http://www.easymock.org/EasyMock2_4_ClassExtension_Documentation.html#Partial_mo
cking
Original comment by JohnnyJianHY
on 5 Feb 2009 at 7:26
Partial mocking have the same effect as issue 52: Mock out single method on
concrete
object. So we should keep strict, nice and maybe stub.
Original comment by julien.g...@gmail.com
on 5 Feb 2009 at 7:32
I thought it is, but actually they are not the same, as partial mock objects
can be
used in Java side while the other one cannot.
Original comment by JohnnyJianHY
on 5 Feb 2009 at 8:14
As Groovy 1.8 supports extended command expression on RHS, I think we can
improve our DSL by removing all parenthesis:
def m = strict mock Date
However, there are odd number of tokens in the expression, so the last "Date"
will be treated as a getter. We need to make it even. My suggestion:
def m1 = strict mock of Date
def m2 = strict and nice mock of Date
What's more, I think we should still support the DSL with parenthesis (def m1 =
strict(mock(Date))), to avoid, maybe, some edge cases of the extended command
expression.
Original comment by JohnnyJianHY
on 24 Dec 2010 at 2:09
I am thinking that "def m1 = strict mock of Date" is not consistent with the
original way of mocking, because of the additional "of".
What about the following ways?
def m1 = mock(Date)
def m2 = strict mock(Date)
def m3 = strict and nice mock(Date)
Original comment by JohnnyJianHY
on 23 May 2011 at 8:45
When we've been talking about strict mock, did we meant ordered? In that case
what about:
def m = ordered(mock(date))
Original comment by julien.g...@gmail.com
on 11 Jun 2011 at 4:19
It is consistent and clear to use the name "ordered mock", but it is usually
called "strict mock" in easymock.
What about support both?
Original comment by JohnnyJianHY
on 12 Jun 2011 at 3:08
Ordered is fine to me.
Original comment by julien.g...@gmail.com
on 12 Jun 2011 at 11:29
Original issue reported on code.google.com by
julien.g...@gmail.com
on 3 Feb 2009 at 6:39