I’m trying to capture an argument using Mockito. This argument is of type List< MyClass >. But I can’t find the proper syntax to specify it.
I can do this:
ArgumentCaptor< MyClass > captor =
ArgumentCaptor.forClass( MyClass.class );
But I don’t get this to compile:
ArgumentCaptor< List<MyClass> > captor =
ArgumentCaptor.forClass( List<MyClass>.class );
Is there a way?
Unfortunately no,
.classwill only return theClass<List>object, whereListis a rawtype. The implementation isn’t perfect, and nested type information can’t be obtained using.class. Something likeList<Foo>.classis invalid syntax because no suchClass<List<Foo>>object exists anywhere.