Mockito isA(Class<T> clazz) How to resolve type safety?
问题 in my test I have the following line: when(client.runTask(anyString(), anyString(), isA(Iterable.class)).thenReturn(...) isA(Iterable.class) produces warning that it needs unchecked conversion to conform to Iterable<Integer> . What is syntax for that? isA(Iterable<Integer>.class) isA((Iterable<Integer>)Iterable.class do not work. Any suggestions? 回答1: Mockito/Hamcrest and generic classes Yes, this is a general problem with Mockito/Hamcrest. Generally using isA() with generic classes produces