【发布时间】:2013-06-03 04:47:41
【问题描述】:
我正在尝试编写一个单元测试,为此我正在为 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 ?>)。它提供了转换我的 userClass,但这只会使一些乱码 eclipse 说它需要再次转换(并且不能转换)。
这只是 Eclipse 的问题,还是我做错了什么?
【问题讨论】: