Mockito matcher and array of primitives

后端 未结 8 1202
既然无缘
既然无缘 2021-01-30 05:53

With Mockito, I want to verify() a method call with byte[] in its argument list, but I didn\'t find how to write this.

 myMethod( byte[         


        
8条回答
  •  爱一瞬间的悲伤
    2021-01-30 06:24

    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 }));
    

提交回复
热议问题