我正在尝试编写一个单元测试,为此我正在为 Mockito 模拟编写一个 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 ?>)
. 它提供了转换我的用户类,但这只会使一些乱码 eclipse 说它需要再次转换(并且不能转换)。
这只是 Eclipse 的问题,还是我做错了什么?