feature request: Mockito.anyTimes()

919 views
Skip to first unread message

rogerdpack

unread,
May 13, 2015, 5:56:44 PM5/13/15
to moc...@googlegroups.com
Hello.  Today I reached for (for some reason) "Mockito.anyTimes()" for an argument captor usage.

Consider this a feature request :)
(I know I can do it with atLeast(0) but that doesn't quite explain clearly intent, at least in my head).
Cheers!
-roger-

Brice Dutheil

unread,
Jun 6, 2015, 6:38:22 PM6/6/15
to moc...@googlegroups.com
Hi,

I have the feeling this doesn't make sense, `anyTimes` feels like such a verification is irrelevant in the test. While TDD is about ensuring interactions happen or not depending a scenario that triggers these interactions or not.

To me if it's irrelevant to the success of the test this verification should be removed. If this is really something wanted, I'd first consider to craft a mockito test util that can match wanted naming conventions.

Cheers,
-- Brice

--
You received this message because you are subscribed to the Google Groups "mockito" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mockito+u...@googlegroups.com.
To post to this group, send email to moc...@googlegroups.com.
Visit this group at http://groups.google.com/group/mockito.
To view this discussion on the web visit https://groups.google.com/d/msgid/mockito/507bce54-9eee-4a23-aa04-707392de0c44%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Wallace

unread,
Jun 6, 2015, 7:02:52 PM6/6/15
to moc...@googlegroups.com
Brice,  I wondered whether Roger was actually looking for a synonym for atLeastOnce().  Yes, I know he said atLeast(0), but to me, that doesn't make too much sense.  

Either way, if this were put to a vote, I'd be voting against having this feature.  As you know, I'm quite opposed to cluttering the API with multiple names for the exact same feature.

Regards,
David.

Brice Dutheil

unread,
Jun 7, 2015, 6:13:44 AM6/7/15
to moc...@googlegroups.com
Agreed, this is not about building a English mocking specific language ;)

For more options, visit https://groups.google.com/d/optout.


--
Brice

Roger Pack

unread,
Jun 8, 2015, 12:33:42 PM6/8/15
to moc...@googlegroups.com
On Sun, Jun 7, 2015 at 4:13 AM, Brice Dutheil <brice....@gmail.com> wrote:
> Agreed, this is not about building a English mocking specific language ;)

OK initially I need/wanted it for something like "assure that this
particular logger logged a message including this string" and I would
iterate over all the messages (even if none) and check them. But
turns out there's a matcher for that anyway (Matchers.contains) but
thanks for the feedback! :)
-roger-
> You received this message because you are subscribed to a topic in the
> Google Groups "mockito" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/mockito/KM1Kd4UR-pg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> mockito+u...@googlegroups.com.
> To post to this group, send email to moc...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mockito.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mockito/CALTMA7sqti-3EzA%2BbpcDf8%2BeyhpStVKvdhTbB3GAJ%3DsHKXK%3DDg%40mail.gmail.com.

Brice Dutheil

unread,
Jun 8, 2015, 7:42:14 PM6/8/15
to moc...@googlegroups.com
You're welcome ; have fun mocking ;)

-- Brice

Reply all
Reply to author
Forward
0 new messages