Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mockito matcher and array of primitives

Tags:

java

mockito

I would try any(byte[].class)


Try this:

AdditionalMatchers.aryEq(array);

I would rather use Matchers.<byte[]>any(). This worked for me.


I agree with Mutanos and Alecio. Further, one can check as many identical method calls as possible (verifying the subsequent calls in the production code, the order of the verify's does not matter). Here is the code:

import static org.mockito.AdditionalMatchers.*;

    verify(mockObject).myMethod(aryEq(new byte[] { 0 }));
    verify(mockObject).myMethod(aryEq(new byte[] { 1, 2 }));

I used Matchers.refEq for this.