when( fooDao.getBar( any(Bazoo.class) )).thenReturn(myFoo);
或(避免
nulls):
when( fooDao.getBar( (Bazoo)notNull() )).thenReturn(myFoo);
不要忘记导入匹配器(有许多其他匹配器可用):
对于Mockito 2.1.0及更高版本:
import static org.mockito.ArgumentMatchers.*;
对于旧版本:
import static org.mockito.Matchers.*;



