Mockito matcher and array of primitives

后端 未结 8 1203
既然无缘
既然无缘 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:32

    What works for me was org.mockito.ArgumentMatchers.isA

    for example:

    isA(long[].class)
    

    that works fine.

    the implementation difference of each other is:

    public static  T any(Class type) {
        reportMatcher(new VarArgAware(type, ""));
        return Primitives.defaultValue(type);
    }
    
    public static  T isA(Class type) {
        reportMatcher(new InstanceOf(type));
        return Primitives.defaultValue(type);
    }
    

提交回复
热议问题