我正在尝试编写一个单元测试,为此我正在为一个Mockito mock编写一个when语句,但是我似乎无法让eclipse识别我的返回值是有效的。
这就是我要做的:
Class<?> userClass = User.class;
when(methodParameter.getParameterType()).thenReturn(userClass);
.getParameterType()
的返回类型是Class<?>
,所以我不明白为什么eclipse会说The method thenReturn(Class<capture#1-of ?>) in the type OngoingStubbing<Class<capture#1-of ?>> is not applicable for the arguments (Class<capture#2-of ?>)
。它提出对我的userClass进行强制转换,但这只是造成了一些乱码,eclipse说它需要再次强制转换(但不能强制转换)。
这只是Eclipse的问题,还是我做错了什么?
https://stackoverflow.com/questions/16890133
复制相似问题