freepascal / mockito

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

ArgumentCaptor matcher is capturing too many values #100

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The internal matcher in ArgumentCaptor captures all of the possible
verification values, not just the actual matched values. For example:

    Service service = mock(Service.class);

    service.someMethod(object1, param1);
    service.someMethod(object2, param2);

    ArgumentCaptor<Object> captor = new ArgumentCaptor<Object>();
    verify(service).someMethod(captor.capture(), eq(param1));

At this point, captor.getAllValues() will return [object1, object2,
object1, object2]. I would expect it to return [object1]. Instead, it
contains two copies of each object ever passed to the method, not just the
one that matched.

A really nasty side effect of this is that captor.getValue() will return
object2, not object1 (despite the fact that I was verifying the call that
took param1).

I'm using 1.8-rc2.

Original issue reported on code.google.com by j...@kikini.com on 25 Jun 2009 at 6:08

GoogleCodeExporter commented 9 years ago
It's great you found it. Thanks a lot for reporting!

This has to be fixed definitely. If you feel like doing the fix and submitting 
the
patch here you're more than welcome. We will definitely fix it before the main 
release.

Original comment by szcze...@gmail.com on 26 Jun 2009 at 9:15

GoogleCodeExporter commented 9 years ago

Original comment by szcze...@gmail.com on 9 Jul 2009 at 12:53

GoogleCodeExporter commented 9 years ago
fixed in trunk

Original comment by szcze...@gmail.com on 19 Jul 2009 at 9:43