Matchers.any() for null value in Mockito

后端 未结 4 1999
夕颜
夕颜 2020-12-25 09:46

Suppose I am having this object objectDemo which calls to the method objectDemoMethod with 2 parameters String and null.

4条回答
  •  庸人自扰
    2020-12-25 10:35

    isNull seems to be deprecated

    With Java 8 this method will be removed in Mockito 3.0. This method is only used for generic friendliness to avoid casting, this is not anymore needed in Java 8.

    I think you could use nullable:

    • public static T nullable(Class clazz)

    You could use something like:

    verify(objectDemo, times(1)).objectDemoMethod(any(String.class), nullable(String.class));
    

提交回复
热议问题