Can Mockito stub a method without regard to the argument?

前端 未结 4 696
离开以前
离开以前 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:37

    http://site.mockito.org/mockito/docs/1.10.19/org/mockito/Matchers.html

    anyObject() should fit your needs.

    Also, you can always consider implementing hashCode() and equals() for the Bazoo class. This would make your code example work the way you want.

提交回复
热议问题