Can Mockito stub a method without regard to the argument?

前端 未结 4 703
离开以前
离开以前 2020-12-12 11:33

I\'m trying to test some legacy code, using Mockito.

I want to stub a FooDao that is used in production as follows:

foo = fooDao.getBar(         


        
4条回答
  •  一个人的身影
    2020-12-12 11:43

    Use like this:

    when(
      fooDao.getBar(
        Matchers.any()
      )
    ).thenReturn(myFoo);
    

    Before you need to import Mockito.Matchers

提交回复
热议问题