mockito return value based on property of a parameter

前端 未结 5 1635
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 19:57

Normally when using mockito I will do something like

Mockito.when(myObject.myFunction(myParameter)).thenReturn(myResult);

Is it possible to do

5条回答
  •  心在旅途
    2021-01-30 20:36

    Yes you can, using a custom argument matcher.

    See the javadoc of Matchers for more details, and more specifically ArgumentMatcher.

提交回复
热议问题