Quantcast
Channel: Using Mockito to mock classes with generic parameters - Stack Overflow
Viewing all articles
Browse latest Browse all 13

Answer by John Paulett for Using Mockito to mock classes with generic parameters

$
0
0

I think you do need to cast it, but it shouldn't be too bad:

Foo<Bar> mockFoo = (Foo<Bar>) mock(Foo.class);when(mockFoo.getValue()).thenReturn(new Bar());

Viewing all articles
Browse latest Browse all 13

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>