freepascal / mockito

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

more convenient varargs matching using anyVararg() #62

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi Szczepan,

I would expect the following test to pass.
What are your thoughts?

Cheers,
felix

public class MockitoVarargTest
{

    interface VarargMethod{
      Object run(String... args);
    }
    @Test
    public void testVarargStubbing(){
        Object returnValue = new Object();
        VarargMethod mock = Mockito.mock(VarargMethod.class);
        when(mock.run((String[]) anyObject())).thenReturn(returnValue);
        assertEquals(returnValue, mock.run("a", "b"));
    }
}

Original issue reported on code.google.com by felix.le...@gmail.com on 12 Mar 2009 at 4:32

GoogleCodeExporter commented 9 years ago
I'll look at it

Original comment by szcze...@gmail.com on 27 Mar 2009 at 11:00

GoogleCodeExporter commented 9 years ago
I think we discussed this issue with patric back at gu, but unfortunately I 
can't
remember, what came out of that...

Original comment by felix.le...@gmail.com on 5 Apr 2009 at 9:19

GoogleCodeExporter commented 9 years ago
It makes sense the anyObject() should match any number of elements in the 
varArg array.

It's fixed in trunk. Thanks Felix for reporting!

Original comment by szcze...@gmail.com on 8 Apr 2009 at 12:15

GoogleCodeExporter commented 9 years ago

Original comment by szcze...@gmail.com on 8 Apr 2009 at 12:15

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago
Reopened as the fix for this bug introduced regression. This is how you 
reproduce it:

        //when
        table.newRow("qux", "foo", "bar", "baz");
        table.newRow("abc", "def");

        //then
        verify(table).newRow(anyString(), eq("foo"), anyString(), anyString());
        verify(table).newRow(anyString(), anyString());

Original comment by szcze...@gmail.com on 11 Jun 2009 at 9:10

GoogleCodeExporter commented 9 years ago
Reverted the fix for this issue as it makes other part of verification broken 
for
some corner cases.

Fix for this issue will go to further milestone.

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

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago
I officially don't have time for this feature :) 

If anyone is keen on this feature, please submit a patch.

Original comment by szcze...@gmail.com on 22 Sep 2009 at 9:04

GoogleCodeExporter commented 9 years ago
This cannot be implemented as it would change the behavior of other parts of the
framework. Namely, it affects counting of actual invocations vs verified 
invocations.

Instead, I introduced new matcher: anyVararg()

Original comment by szcze...@gmail.com on 9 Nov 2009 at 10:10

GoogleCodeExporter commented 9 years ago
That's great! Any release plans yet?

Original comment by aberran...@gmail.com on 10 Nov 2009 at 1:07

GoogleCodeExporter commented 9 years ago
I'm working on it - should be couple of days :)

Original comment by szcze...@gmail.com on 10 Nov 2009 at 10:15

GoogleCodeExporter commented 9 years ago

Original comment by szcze...@gmail.com on 11 Nov 2009 at 1:33

GoogleCodeExporter commented 9 years ago

Original comment by szcze...@gmail.com on 11 Nov 2009 at 2:45