Mockito: Verifying with generic parameters

后端 未结 4 1028
北海茫月
北海茫月 2020-12-02 19:34

With Mockito I can do the following:

verify(someService).process(any(Person.class));

But how do I write this if process takes

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 20:08

    if you use a own method, you can even use static import:

    private Collection anyPersonCollection() {
        return any();
    }
    

    Then you can use

    verify(someService).process(anyPersonCollection());
    

提交回复
热议问题