Re: [mockito] argThat with verify causes NullPointerException

180 views
Skip to first unread message

Eric Lefevre-Ardant

unread,
Sep 26, 2012, 5:25:29 AM9/26/12
to moc...@googlegroups.com
hm... I had never tried that before, but it does seem to work for me. Here is something that worked fine in my own tests:

    verify(configurationClient).setHost(org.mockito.Matchers.argThat(org.hamcrest.CoreMatchers.not(org.hamcrest.CoreMatchers.equalTo("host"))));
    verify(configurationClient, org.mockito.Mockito.never()).setHost(org.mockito.Matchers.argThat(org.hamcrest.CoreMatchers.not(org.hamcrest.CoreMatchers.equalTo("host"))));

Maybe you are not importing the right classes/static imports?


On 26 September 2012 10:38, Aaron VonderHaar <gruen0...@gmail.com> wrote:
I'm getting a NullPointerException when I try to use argThat with verify:

    import static org.hamcrest.CoreMatchers.equalTo;
    // Causes NPE
    verify(collaborator, never()).doSomething(eq("String"), argThat(equalTo(1)));

But other argument matchers seem to work:

    // This works as expected
    verify(collaborator, never()).doSomething(eq("String"), eq(1));


Am I using argThat incorrectly?  I need to use argThat because (unlike the example above), I want to check argThat(not(equalTo(1))).  I'm getting the same NPE whether or not I use never().  I'm using mockito-1.9.5-rc1, hamcrest-1.2.1 and junit-4.10.

Thanks,
--Aaron V.

--
You received this message because you are subscribed to the Google Groups "mockito" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mockito/-/yJD14xqksUgJ.
To post to this group, send email to moc...@googlegroups.com.
To unsubscribe from this group, send email to mockito+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mockito?hl=en.

Brice Dutheil

unread,
Sep 26, 2012, 8:16:16 AM9/26/12
to moc...@googlegroups.com
Hi,

Where the NPE is coming from (stack trace) ?

-- Brice
Reply all
Reply to author
Forward
0 new messages