Using Mockito to mock classes with generic parameters

后端 未结 7 1854
不知归路
不知归路 2020-11-30 19:37

Is there a clean method of mocking a class with generic parameters? Say I have to mock a class Foo which I need to pass into a method that expects a <

相关标签:
7条回答
  • 2020-11-30 20:04

    As the other answers mentioned, there's not a great way to use the mock() & spy() methods directly without unsafe generics access and/or suppressing generics warnings.

    There is currently an open issue in the Mockito project (#1531) to add support for using the mock() & spy() methods without generics warnings. The issue was opened in November 2018, but there aren't any indications whether it will be prioritized.

    0 讨论(0)
提交回复
热议问题