freepascal / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

Easier verifications on the same method of multiple objects of the same type #87

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hey all,

I have some tests that use the InOrder object to verify that methods are
called in order.  The thing is, the mock types that I'm verifying are the
same and the method I'm verifying is being called is the same method.  So,
it looks like

        InOrder inOrder = inOrder(redFilter(), orangeFilter(), pinkFilter());
        inOrder.verify(redFilter()).doFilter(same(request), same(response),
isA(AggregateFilterChain.class));
        inOrder.verify(pinkFilter()).doFilter(same(request),
same(response), isA(AggregateFilterChain.class));
        inOrder.verify(orangeFilter()).doFilter(same(request),
same(response), isA(AggregateFilterChain.class));

And I have this same pattern in multiple places, which is really blowing up
the size of the tests and obscuring their purpose.  It would be much better
if it could be more like

        verify(inOrder(redFilter(), orangeFilter(),
pinkFilter())..doFilter(same(request), same(response),
isA(AggregateFilterChain.class));

Original issue reported on code.google.com by rwallace...@gmail.com on 25 May 2009 at 4:57

GoogleCodeExporter commented 9 years ago
Hi,

Feedback about the interface you proposed:

verify(inOrder(redFilter(), orangeFilter(), pinkFilter())
  .doFilter(same(request), same(response), isA(AggregateFilterChain.class));

I would prefer to avoid introducing new method to the API. We should strive to
implement new functionality with current API to keep things simple & concise. 
Any ideas?

This is a bit funky but at least it is implementable within the API (you can try
implementing it, without changing Mockito I suppose):

verify(redFilter, then(orangeFilter).then(pinkFilter))
  .doFilter(same(request), same(response), isA(AggregateFilterChain.class));

Original comment by szcze...@gmail.com on 25 May 2009 at 5:52

GoogleCodeExporter commented 9 years ago

Original comment by szcze...@gmail.com on 25 May 2009 at 5:52

GoogleCodeExporter commented 9 years ago

Original comment by szcze...@gmail.com on 17 Jun 2009 at 12:25

GoogleCodeExporter commented 9 years ago
It's a very rare case and no one else asked about it.

Original comment by szcze...@gmail.com on 14 Feb 2010 at 10:10