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 <
Foo
I think you do need to cast it, but it shouldn't be too bad:
Foo mockFoo = (Foo) mock(Foo.class); when(mockFoo.getValue()).thenReturn(new Bar());